npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@ciri/ngx-carousel

v0.0.4

Published

A simple angular carousel component.

Downloads

84

Readme

NgxCarousel

A simple angular carousel component.

👉 Live Demo

✨ Features

  • Support pc & mobile
  • Support custom indicator
  • Support lazy render

💻 Environment Support

  • Only tested angular 8.3.29

📦 Install & Usage

npm i @ciri/ngx-carousel
# or
yarn add @ciri/ngx-carousel

Add it to your module:

import { CarouselModule } from '@ciri/ngx-carousel'

@NgModule({
  // ...
  imports: [
    // ...
    CarouselModule
  ],
})
<ngx-carousel [loop]="true">
  <ngx-carousel-item>
    <div class="demo-content" style="background: #FAF9D6">1</div>
  </ngx-carousel-item>

  <ngx-carousel-item>
    <div class="demo-content" style="background: #F4B9C1">2</div>
  </ngx-carousel-item>

  <ngx-carousel-item>
    <div class="demo-content" style="background: #96CDF6">3</div>
  </ngx-carousel-item>
</ngx-carousel>

🎨 Custom Indicator

<style>
  .custom-indicator {
    position: absolute;
    bottom: 0;
    right: 0;
    padding: 0 10px;
    background: rgba(0, 0, 0, 0.3);
    color: #fff;
  }
</style>
<ngx-carousel [indicator]="indicator" [loop]="true">
  <ngx-carousel-item>
    <div class="demo-content" style="background: #FAF9D6">1</div>
  </ngx-carousel-item>

  <ngx-carousel-item>
    <div class="demo-content" style="background: #F4B9C1">2</div>
  </ngx-carousel-item>

  <ngx-carousel-item>
    <div class="demo-content" style="background: #96CDF6">3</div>
  </ngx-carousel-item>

  <ng-template #indicator let-data>
    <div class="custom-indicator">
      {{ data.active + 1 }} / {{ data.count }}
    </div>
  </ng-template>
</ngx-carousel>

🐷 Lazy Render

You can use ng-template + lazyRender to implement lazy loading

<ngx-carousel [loop]="true">
  <ngx-carousel-item>
    <div class="demo-content" style="background: #FAF9D6">I'm not lazy</div>
  </ngx-carousel-item>

  <ngx-carousel-item>
    <ng-template lazyRender>
      <div class="demo-content" style="background: #F4B9C1">I'm lazy</div>
    </ng-template>
  </ngx-carousel-item>

  <ngx-carousel-item>
    <ng-template lazyRender>
      <div class="demo-content" style="background: #96CDF6">I'm lazy</div>
    </ng-template>
  </ngx-carousel-item>
</ngx-carousel>

🎁 Inputs

| Name | Type | Default | Description | | ---------------- | ----------------------------------------------------------- | ------- | -------------------------------------------------------- | | initialIndex | number | 0 | Initial index | | loop | boolean | false | Whether to enable loop | | speed | number | 300 | Animation duration (ms) | | autoplay | number | 0 | Autoplay interval (ms),0 means turn off autoplay | | followFinger | boolean | true | If false, move only when you release your finger | | allowTouchMove | boolean | true | If false, you can only use api to slide | | indicator | TemplateRef<{ $implicit: CarouselData }> | - | Custom indicator | | lazyRenderOffset | number | 0 | Number of pre-rendered offsets (left and right) | | cache | boolean | true | Cache rendered items |

🐚 Outputs

| Event | Description | Return value | | ------ | ------------------------------------ | ------------ | | change | Triggered when current slider change | index |

🧩 Properties & Methods

| Name | Type | Description | | ------ | -------------------------------------------- | ------------------------------------------------------------------------------------------------------ | | data | CarouselData | Some component raw data | | goTo | (target: number, immediate: boolean) => void | Slide to target index, params:target: Target indeximmediate: Whether to skip animation | | prev | () => void | Slide to prev slider | | next | () => void | Slide to next slider | | resize | () => void | Recalculate size of sliders |

🍬 CarouselData

| Name | Description | | --------- | ------------------------------- | | active | The index of the current slider | | count | Total number of sliders | | offset | Carousel offset (%) | | animating | True if in transition |