Path Slider
Sliding elements along SVG paths!
Basic Usage Links
Advanced Usage Links
Codepen Elastic | Codepen Images
Documentation
PathSlider
constructor ask for 3 parameters:
path
: SVG path (or String selector) to slide elements through ititems
: DOM elements (or String selector) to slideoptions
: Object with options to override defaults
For example:
var options = {startLength: 0};
var mySlider = new PathSlider('.path', '.item', options);
options
:
Possible startLength
(float or 'center'): Length of the path to start positioning the elementsactiveSeparation
(float): Separation among the active item and adjacent itemspaddingSeparation
(float): Padding separation at the beginning and the end of the pathduration
,delay
,easing
,elasticity
: Refer to anime.js library optionsstagger
(ms): Delay among animations of each itembegin
(function): Callback function to call immediately before each item animation startsend
(function): Callback function to call immediately after each item animation endsbeginAll
(function): Callback function to call immediately before all the animations startsendAll
(function): Callback function to call immediately after all the animations endsblockUntilEnd
(boolean): Iftrue
(false by default), you need to wait current animation ends to select a new itemclickSelection
(boolean): Iftrue
(default), add listeners forclick
events in every item to allow selecting them
begin
and end
receive an object with some useful info:
Callback functions index
: Index of itemnode
: The DOM nodeselected
: True if item has been selectedunselected
: True if item has been unselected
Selecting items:
By default, the library add listeners for click
events in every item to allow selecting them (clickSelection
option). You can also select items using the following functions:
selectPrevItem()
: Select the prev itemselectNextItem()
: Select the next itemselectItem(index)
: Select any item using the correspondingindex
For example:
mySlider.selectPrevItem(); // Or any of the following
// mySlider.selectNextItem();
// mySlider.selectItem(0);