0.0.8 • Published 1 year ago

ngx-carouselx v0.0.8

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

NGX CAROUSELX

a simple carousel that supports latest angular versions and easy to use.

Features

  • NgxCarouselx has no dependencies besides angular. All animations are 100% CSS, so @angular/animations is not needed.
  • Responsive and captures swipes from phones and tablets
  • Lazy load option to help with initial pageload speed

History

This project is a fork and continuation of the now-discontinued ng-simple-slideshow created by Richard Jeffords. Our current focus is to maintain package security and ensure compatibility with the latest Angular version. We welcome pull requests, including bug fixes, upgrades, and enhancements to the component.

Installation

Easy, just npm install:

npm i ngx-carouselx

Next, import the standalone carousel component:

import { CarouselComponent } from 'ngx-carouselx';

@Component({
  ...
  imports: [
    CarouselComponent,
    ...
  ],
  ...
})
...

Usage

The simplest use case is the following:

<carouselx [imageUrls]="imageUrlArray"></carouselx>

A more complex example below (full list of options in next section):

<carouselx [height]="height"
           [minHeight]="'525px'"
           [autoPlay]="true"
           [showArrows]="false"
           [imageUrls]="imageSources"
           [lazyLoad]="imageSources?.length > 1"
           [autoPlayWaitForLazyLoad]="true">
</carouselx>

Options

Inputs

OptionRequiredDefaultTypeDescription
imageUrlsyes[]string[] or IImage[]array of image urls or IImage
heightno'100%'stringCSS height of carousel
minHeightnostringCSS min-height of carousel
arrowSizeno'30px'stringlength of arrow lines
showArrowsnotruebooleanshow or hide the arrows
disableSwipingnofalsebooleanturn swipe detection on or off
autoPlaynofalsebooleanturn autoPlay on or off
autoPlayIntervalno3333numbertime in ms between autoPlay slides
stopAutoPlayOnSlidenotruebooleanstop autoPlay if carousel is interacted with
autoPlayWaitForLazyLoadnotruebooleanautoplay to waits for images to lazy load before changing slides
backgroundSizeno'cover'stringoverwrite background-size property
backgroundPositionno'center center'stringoverwrite background-position property
backgroundRepeatno'no-repeat'stringoverwrite background-repeat property
showDotsnofalsebooleanshow clickable dots at the bottom
dotColorno'#FFF'stringcolor of clickable dots at the bottom
showCaptionsnotruebooleanshow or hide captions
captionColorno'#FFF'stringcolor of caption text
captionBackgroundno'rgba(0, 0, 0, .35)'stringcolor of caption background
lazyLoadnofalsebooleanturn on to lazy load images instead of preload
hideOnNoSlidesnofalsebooleanset the carousel container display to none if imageUrls is empty, null, or undefined
fullscreennofalsebooleanactivate full screen for the carousel on true, go back to normal view on false
enableZoomnofalsebooleanenable (2 point/pinch) touch zoom in/out on images
enablePannofalsebooleanenable (1 point) touch/click panning of images, NOTE: "true" will disable image on click actions
noLoopnofalsebooleanblock looping through carousel like a circular list

Output Events

EventDescription
onSlideLeftwhen the left arrow is clicked
onSlideRightwhen the right arrow is clicked
onSwipeLeftwhen a swipe left occurs
onSwipeRightwhen a swipe right occurs
onFullscreenExitwhen fullscreen exits
onIndexChangedwhen slide index changes
onImageLazyLoadwhen slide image lazy loads
onClickwhen slide (not arrows) is clicked

Note: all events emit the index number of the new slide, with the exception of onClick which returns the slide object in addition to the index.

API

Take control of the ngx-carouselx if you want! Simply create a reference to your carousel like so:

<carouselx #carousel [imageUrls]="imageUrlArray"></carouselx>

and in your component.ts reference it as a ViewChild:

@ViewChild('carousel') carousel: any;

Now you can access the public members such as the goToSlide and onSlide:

this.carousel.goToSlide(3); // go to slide index 3 (i.e. imageUrls[3])
this.carousel.onSlide(1); // next slide
this.carousel.onSlide(-1); // previous slide
0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago