Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

ng-simple-slideshow

dockleryxk14kMIT1.2.9TypeScript support: included

A simple, responsive slideshow for Angular 4+.

angular, angular 2, angular 4, angular 5, angular 6, ng, ngx, ng2, ng4, ng5, ng6, slideshow, carousel, slider, angular2, angular4, angular5, angular6

readme

 _  _      ___ _            _     ___ _ _    _        _
| \| |__ _/ __(_)_ __  _ __| |___/ __| (_)__| |___ __| |_  _____ __ __
| .` / _` \__ \ | '  \| '_ \ / -_)__ \ | / _` / -_|_-< ' \/ _ \ V  V /
|_|\_\__, |___/_|_|_|_| .__/_\___|___/_|_\__,_\___/__/_||_\___/\_/\_/
     |___/            |_|

Note (09/2019):

v1.3.0-beta.2 will be in beta until I update the way ng-packagr works. It is stable enough for production (it's what I am using with Angular Universal and Service Worker).

Also, I am looking for maintainers who also using this package in a production app. I have this requirement because I need maintainers who have a vested interest in the quality of this package. Thanks.

A simple slideshow for Angular 4+.

Click here the check out the demo. Click here the see the slideshow in production on a StoragePug client site, which is what I originally made this slideshow package for.

Features

  • NgSimpleSlideshow has no dependencies besides angular. All animations are 100% CSS, so @angular/animations is not needed.
  • Compiled and packaged in the Angular Package Format v4.0 with ng-packagr.
  • Compiled to es5, so this package is compatible with Angular Universal.
  • AOT ready
  • Responsive and captures swipes from phones and tablets
  • Lazy load option to help with initial pageload speed

Installation

Easy, just npm install:

npm i -S ng-simple-slideshow

Next, import the module:

import {SlideshowModule} from 'ng-simple-slideshow';

@NgModule({
  imports: [
    SlideshowModule,
    ...
  ],
  declarations: [
    ...
  ],
  exports: [
    ...
  ]
})
...

Usage

The simplest use case is the following:

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

A more complex example of how I use this in one of my own projects (full list of options in next section):

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

More Info on imageUrls

The imageUrls input can be an array of strings, however in order to enable slides to have links, captions, or custom click functions, you must use an object of type IImage instead of a string. For example usage, see here.

Options

Inputs

Option Required Default Type Description
imageUrls yes [] string[] or IImage[] array of image urls or IImage
height no '100%' string CSS height of slideshow
minHeight no | string CSS min-height of slideshow
arrowSize no '30px' string length of arrow lines
showArrows no true boolean show or hide the arrows
disableSwiping no false boolean turn swipe detection on or off
autoPlay no false boolean turn autoPlay on or off
autoPlayInterval no 3333 number time in ms between autoPlay slides
stopAutoPlayOnSlide no true boolean stop autoPlay if slideshow is interacted with
autoPlayWaitForLazyLoad no true boolean autoplay to waits for images to lazy load before changing slides
backgroundSize no 'cover' string overwrite background-size property
backgroundPosition no 'center center' string overwrite background-position property
backgroundRepeat no 'no-repeat' string overwrite background-repeat property
showDots no false boolean show clickable dots at the bottom
dotColor no '#FFF' string color of clickable dots at the bottom
showCaptions no true boolean show or hide captions
captionColor no '#FFF' string color of caption text
captionBackground no 'rgba(0, 0, 0, .35)' string color of caption background
lazyLoad no false boolean turn on to lazy load images instead of preload
hideOnNoSlides no false boolean set the slideshow container display to none if imageUrls is empty, null, or undefined
fullscreen no false boolean activate full screen for the slideshow on true, go back to normal view on false
enableZoom no false boolean enable (2 point/pinch) touch zoom in/out on images
enablePan no false boolean enable (1 point) touch/click panning of images, NOTE: "true" will disable image on click actions
noLoop no false boolean block looping through slideshow like a circular list

Output Events

Event Description
onSlideLeft when the left arrow is clicked
onSlideRight when the right arrow is clicked
onSwipeLeft when a swipe left occurs
onSwipeRight when a swipe right occurs
onFullscreenExit when fullscreen exits
onIndexChanged when slide index changes
onImageLazyLoad when slide image lazy loads
onClick when 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 slideshow if you want! Simply create a reference to your slideshow like so:

<slideshow #slideshow [imageUrls]="imageUrlArray"></slideshow>

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

@ViewChild('slideshow') slideshow: any;

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

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

changelog

Changelog

Starting March 17, 2018 all notable changes to this project will be documented in this file. The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

[Unreleased]

  • Angular Universal (server side rendered) demo
  • Refactor code to this format

[1.3.0-beta.11] - 2020-3-13

  • Update peer dependencies

Changed

  • Merge #102 to support Angular 9/Ivy renderer -- issue -

[1.3.0-beta.10] - 2020-3-3

Changed

  • Merge #102 to support Angular 9/Ivy renderer -- issue

[1.3.0-beta.9] - 2019-12-15

Changed

  • Don't share PointerService across slideshows to prevent slides moving at the same time -- issue

[1.3.0-beta.8] - 2019-11-27

Changed

  • Reverted: replace "left" with "translate3d" for a better performance -- pull reverted because of bug on iOS and Safari

[1.3.0-beta.6] - 2019-11-03

Changed

  • Prevent default on click events
  • Add tabindex="-1" on slide elements
  • Apply fix to index reset for non-lazy loaded slideshows

[1.3.0-beta.5] - 2019-11-01

Changed

  • Use different href placeholder per stackoverflow. I am really glad that website exists!

[1.3.0-beta.4] - 2019-10-31

Added

  • Click event emitter -- issue

[1.3.0-beta.3] - 2019-10-31

Changed

  • Fix issue where the index kept resetting to zero while adding new urls -- pull
  • Replaced "left" with "translate3d" for a better performance -- pull

[1.3.0-beta.2] - 2019-06-12

Added

  • noLoop input to add non-repeating slideshow functionality -- issue
  • onImageLazyLoad event emitter when an image lazy loads -- issue

Changed

  • ChangeDetectionStrategy is now onPush -- issue
  • autoPlayWaitForLazyLoad now defaults to true instead of false

[1.3.0-beta.1] - 2019-06-12

Changed

  • Added some safeguards to prevent trying to access slides that don't exist
  • Updated to support Angular 8

[1.3.0-beta.0] - 2019-06-11

Changed

  • Merge Pull #68: zoom & pan -- pull

[1.2.9] - 2019-03-21

Changed

  • Merge Pull #60: stopped event propagation on fullscreen exit buttonm added new fullscreen exit event, and fullscreen exit button position is now fixed to view port rather than absolute to relative parent element -- pull

[1.2.8] - 2019-02-06

Changed

  • Merge Pull #58 for AutoPlay option working as a Play/Pause button -- pull
  • Merge Pull #56 for fullscreen implementation on bindable input -- pull

[1.2.7] - unknown

Changed

  • run setInterval outside of Angular zone

[1.2.6] - 2018-10-24

Added

  • Use trackBy in the array of images

Changed

  • Removed output aliasing
  • Updated to support Angular 7

[1.2.5] - 2018-09-15

Added

  • hideOnNoSlides which sets the container element style to display:none if no slides exists, or if the imageUrls array's length is zero

Changed

  • imageUrls array can now be empty, null, or undefined

[1.2.4] - 2018-08-26

Added

  • backgroundPosition, backgroundRepeat, and backgroundSize props added to the IImage interface. This adds the ability to set these properties for each slide individually. These properties will default to the slideshow inputs

[1.2.3] - 2018-07-08

Changed

  • Merge Pull #23 for custom click functions -- pull
  • Remove "next" and "previous" text -- issue

[1.2.2] - 2018-05-17

Changed

  • Update npm tags

[1.2.1] - 2018-05-17

Changed

  • Fix this bug because of bad compilation -- issue

[1.2.0] - 2018-05-13

Changed

  • Update peer dependency for Angular 6

[1.1.19] - 2018-04-18

Changed

  • imageUrl array initialized to []
  • make default height 100% from the ts instead of scss

[1.1.18] - 2018-04-14

Changed

  • actually make sure slides without hrefs don't redirect

[1.1.17] - 2018-04-14

Changed

  • Make sure slides without hrefs don't redirect -- bug report
  • Use the document from angular core instead of the window object
  • add ability to use titles in anchor tags for images

Breaking Changes

  • use a css spinner instead of a gif, remove option

[1.1.16] - 2018-03-20

Changed

  • Fix glitchy-looking UX by removing slide from transfer state after using it once

[1.1.15] - 2018-03-20

Changed

  • Better lazy loading for server side rendered applications

[1.1.14] - 2018-03-20

Changed

  • Lazy loading logic now lets DOM load completely before continuing to load images

[1.1.13] - 2018-03-20

Changed

  • Bug fix for lazy loading

[1.1.11] - 2018-03-19

Added

  • Spinner in place of blank space while images are lazy loading
  • Option for url to custom spinner gif
  • Option for autoplay to wait for images to lazy load before changing slides

Changed

  • Improved lazy loading

[1.1.10] - 2018-03-18

Added

  • Option to turn captions on or off, regardless if the slides have them

[1.1.9] - 2018-03-18

Added

  • Lazy Loading

[1.1.8] - 2018-03-17

Changed

  • fix async binding error -- issue

[1.1.7] - 2018-03-17

Changed

  • fix image url binding update -- issue

[1.1.6] - 2018-03-17

Added

  • Option to change dot color -- issue
  • Option to change caption text color
  • Option to change caption background

[1.1.5] - 2018-03-17

Changed

  • Slider as a tags instead of div tags for SEO -- pull
  • Optional image caption -- pull

[1.1.4] - 2018-03-17

Added

  • This changelog!

Changed

  • Updated packages to fix vulernable dependency -- ssri