API
Slider Revolution API
Extend the slider’s functionality with API methods and events.
Extend the slider’s functionality with API methods and events. All of the available methods and events are listed in this section of the slider’s settings, and can be copied and pasted directly from this section into the slider’s Custom JavaScript section.
Each slider will have its own unique API variable which is based on the slider’s ID. In the screenshot to the right, the API variable is “revapi5”, but this will vary depending on your particular slider.
Hover your mouse over each code sample for brief explanations of each method or event.
The following is a quick sample of using the slider’s API, where we’ll pause the slider when the second to last slide is shown.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
// listen for when the slider initially loads revapi5.bind('revolution.slide.onloaded', function() { console.log('Slider Loaded'); // get number of total slides in slider var totalSlides = revapi5.revmaxslide(); // listen for when a new slide is shown revapi5.bind('revolution.slide.onchange', function(e, data) { // get current slide number var currentSlide = data.slideIndex; // pause slider at the second to last slide if(currentSlide === totalSlides - 1) { console.log('Slider Paused'); revapi5.revpause(); } }); }); |