Auto Scroll
Overview
The Auto Scroll extension continuously scrolls the slider. This goes well with "Drag Free" mode.
- 04
- 05
- 06
- 07
- 08
- 09
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 01
- 02
- 03
- 04
- 05
- 06
This extension is compatible with the Intersection extension that allows you to start auto scroll only when the slider is in the viewport.
Installation
NPM
Get the latest version by NPM:
$ npm install @splidejs/splide-extension-auto-scroll
$ npm install @splidejs/splide-extension-auto-scroll
Then, mount the extension to Splide:
import{Splide}from'@splidejs/splide';import{AutoScroll}from'@splidejs/splide-extension-auto-scroll';newSplide('.splide').mount({AutoScroll});JavaScript
import { Splide } from '@splidejs/splide';
import { AutoScroll } from '@splidejs/splide-extension-auto-scroll';
new Splide( '.splide' ).mount( { AutoScroll } );
CDN or Hosting Files
Visit jsDelivr and get the link of the latest file, or download files from the dist directory. And then, import the minified script on your site:
<scriptsrc="path-to-the-script/splide-extension-auto-scroll.min.js"></script>HTML
<script src="path-to-the-script/splide-extension-auto-scroll.min.js"></script>
After importing files, mount the extension to Splide:
newSplide('.splide').mount(window.splide.Extensions);JavaScript
new Splide( '.splide' ).mount( window.splide.Extensions );
Options
This extension takes several options as autoScroll:
newSplide('.splide',{autoScroll:{speed:2,},});JavaScript
new Splide( '.splide', {
autoScroll: {
speed: 2,
},
} );
speed
speed: number = 1The scroll speed as pixel/frame.
autoStart
autoStart: boolean = trueDetermines whether to start scrolling the slider after initialization.
rewind
rewind: booleanDetermines whether to rewind the slider when it reaches the end.
pauseOnHover
pauseOnHover: boolean = trueDetermines whether to pause the auto scroll when the cursor is on the slider.
pauseOnFocus
pauseOnFocus: boolean = trueDetermines whether to pause the auto scroll when the slider contains an active element.
Methods
play()
play(): voidStarts scrolling the slider.
pause()
pause(): voidPauses auto scroll.