Slider JS API
SA5 Slider Code Examples
Manipulating the Slider
Outside of callback events, you can also access the SA5 Slider object by constructing one explicitly;
const slider = new sa5.WebflowSlider(
document.querySelector('[wfu-slider=demo1]')
);Once you have this, you can call its methods and properties;
Properties;
nameproperty returns the[wfu-slider]name, if one was set.currentIndexgets or sets the 0-based index of the current slide ( i.e. 5 slides would be numbered 0, 1, 2, 3, 4 ).currentNumgets or sets the 1-based index of the current slide ( i.e. 5 slides would be numbered 1, 2, 3, 4, 5 ).
Methods;
goToFirst()navigates to the first slidegoToLast()navigates to the last slidegoToPrev()navigates to the prev slidegoToNext()navigates to the next slide
See Slider Code Examples for more.
These examples assume that;
You have a Slider
The Slider has a
wfu-sliderattribute with a value ofslider1You have the SA5 library installed
Navigating Slides
Here we'll use jQuery as
First, setup the slider object-
document.addEventListener('DOMContentLoaded', function() {
// Initialize SA5 Webflow Tabs
sliderDemo = new sa5.WebflowSlider(
document.querySelector('[wfu-slider=slider1]')
);
// Perform any initial setup
// e.g. select slide #2
sliderDemo.currentNum = 2;
console.log(sliderDemo);
});Setup any buttons or other triggers you want, to perform other navigations.
For example, suppose we have a button with an ID of buttonNext and we want it to navigate to the next slide;
// On button click, navigate to next slide
document.querySelector('#buttonNext').addEventListener('click', function() {
sliderDemo.goToNext();
});Last updated
Was this helpful?