Events and Methods
Learn how to integrate Zoro Slider with frontend runtime events, public methods, custom events, and callback functions.
Events and Methods
Zoro Slider supports integration in three main ways:
- frontend runtime events emitted by the slider
- builder-configured layer actions such as custom events and callback functions
- public runtime methods you can call from your theme, plugin, or page scripts
This page documents both the public frontend API exposed by the slider runtime and the layer-side integration patterns you can test immediately. For the full layer-side setup of custom events, callback functions, and advanced actions, also see Layer Options.
Frontend Runtime Events
The frontend slider runtime emits zoroslider:* events that you can listen to from your page scripts.
Lifecycle events
zoroslider:initzoroslider:readyzoroslider:destroyzoroslider:error
Slide navigation events
zoroslider:before-slide-changezoroslider:slide-change-startzoroslider:slide-changezoroslider:slide-change-endzoroslider:slide-change-cancelzoroslider:after-slide-change
Autoplay events
zoroslider:autoplay-startzoroslider:autoplay-stopzoroslider:autoplay-pausezoroslider:autoplay-resumezoroslider:autoplay-progresszoroslider:autoplay-complete
Interaction events
zoroslider:nextzoroslider:previouszoroslider:slide-tozoroslider:swipezoroslider:keyboard-navigationzoroslider:control-clickzoroslider:dot-clickzoroslider:thumb-click
Layer events
zoroslider:layer-before-inzoroslider:layer-after-inzoroslider:layer-before-outzoroslider:layer-after-outzoroslider:layer-clickzoroslider:layer-showzoroslider:layer-hide
Transition events
zoroslider:transition-startzoroslider:transition-endzoroslider:transition-cancel
Responsive events
zoroslider:resizezoroslider:layout-changezoroslider:device-change
Carousel events
zoroslider:carousel-movezoroslider:carousel-movedzoroslider:carousel-item-click
Media events
zoroslider:media-readyzoroslider:media-playzoroslider:media-playingzoroslider:media-pausezoroslider:media-endedzoroslider:media-time-updatezoroslider:media-seekedzoroslider:media-volume-changezoroslider:media-error
Video-specific events
zoroslider:video-readyzoroslider:video-playzoroslider:video-playingzoroslider:video-pausezoroslider:video-endedzoroslider:video-volume-changezoroslider:video-enter-fullscreenzoroslider:video-exit-fullscreenzoroslider:video-error
Audio-specific events
zoroslider:audio-readyzoroslider:audio-playzoroslider:audio-playingzoroslider:audio-pausezoroslider:audio-endedzoroslider:audio-volume-changezoroslider:audio-error
Listening for runtime events
Example 1: Using jQuery
jQuery('#my-slider').on('zoroslider:after-slide-change', function (e, detail) {
console.log(detail && detail.currentIndex);
});
Example 1: Using Vanilla JavaScript
document
.getElementById('my-slider')
.addEventListener('zoroslider:after-slide-change', function (e) {
const detail = e.detail;
console.log(detail && detail.currentIndex);
});
Example 2: Using jQuery
$('#my-slider').on('zoroslider:after-slide-change', (e) => {
const detail = e.originalEvent.detail;
console.log(detail.currentIndex);
});
Example 2: Using Vanilla JavaScript
const slider = document.getElementById('my-slider');
slider.addEventListener('zoroslider:after-slide-change', (e) => {
const detail = e.detail;
console.log(detail.currentIndex);
});
Depending on the event source, detail may also be available through the event object. If you are wiring up custom logic, inspect the event once in the browser console first.
Public Runtime Methods
The runtime stores a public API handle on the slider element as zorosliderapi.
Example Using jQuery
const api = jQuery('#my-slider').data('zorosliderapi');
Example Using Vanilla JavaScript
const api = document.getElementById('my-slider').dataset.zorosliderapi;
Navigation methods
next()previous()goTo(index)goToFirst()goToLast()
State and slide information methods
getCurrentIndex()getPreviousIndex()getSlideCount()getCurrentSlide()getSlide(index)isAnimating()isPaused()isAutoplayEnabled()
Autoplay methods
startAutoplay()pauseAutoplay()resumeAutoplay()stopAutoplay()restartAutoplay()
Slider lifecycle and layout methods
destroy()refresh()update()refreshLayout()setLayout(layout)getLayout()getDevice()
Layer methods
showLayer(layer)hideLayer(layer)toggleLayer(layer)removeLayer(layer)addLayer(configOrElement)animateLayerIn(layer, delay)animateLayerOut(layer, delay)toggleLayerAnimation(layer, inDelay, outDelay)triggerLayerClick(layer)
Media methods
playMedia(selectorOrLayer)pauseMedia(selectorOrLayer)stopMedia(selectorOrLayer)muteMedia(selectorOrLayer)unmuteMedia(selectorOrLayer)setMediaVolume(selectorOrLayer, volume)
Scrolling methods
scrollToSliderTop(offset)scrollToSliderBottom(offset)scrollToPageTop(offset)scrollToPageBottom(offset)scrollToElement(element, offset)
Options and API access methods
getOption(name)setOption(name, value)getOptions()getSlides()getApi()
Public method example
Example Using jQuery
const api = jQuery('#my-slider').data('zorosliderapi');
if (api) {
api.goTo(3);
api.pauseAutoplay();
}
Example Using Vanilla JavaScript
const slider = document.getElementById('my-slider');
const api = slider.dataset.zorosliderapi;
if (api && typeof api.goTo === 'function' && typeof api.pauseAutoplay === 'function') {
api.goTo(3);
api.pauseAutoplay();
}
Recommended Integration Order
If you are adding custom behavior to a slider, use this order:
- build the slider and save it
- assign a stable layer ID in the layer settings
- configure the layer action in the builder
- test it on preview
- test it again on the frontend page where the slider is embedded
This helps you separate builder configuration problems from theme or frontend script problems.
Layer Custom Events
The most reliable event-driven integration path is the layer Custom Event action.
In the builder:
- select a layer
- open
Layer Settings - go to the
Advancedarea - add an action row
- set
EventtoCustom Event - enter an
Event Namesuch aspromoOpen - choose the action behavior you want to trigger
jQuery trigger example
jQuery('#your-layer-id').trigger('promoOpen');
jQuery button-to-layer example
jQuery(function ($) {
$('#open-promo-button').on('click', function () {
$('#your-layer-id').trigger('promoOpen');
});
});
Vanilla JavaScript trigger example
document
.getElementById('your-layer-id')
.dispatchEvent(new Event('promoOpen', { bubbles: true }));
Vanilla JavaScript button-to-layer example
document.addEventListener('DOMContentLoaded', function () {
const button = document.getElementById('open-promo-button');
const layer = document.getElementById('your-layer-id');
if (!button || !layer) {
return;
}
button.addEventListener('click', function () {
layer.dispatchEvent(new Event('promoOpen', { bubbles: true }));
});
});
Callback Function Actions
Zoro Slider supports callback-driven actions from the layer action settings. Use them when a layer event should call custom JavaScript in your site.
Inline Callback Type
Use Inline when the callback logic is short and specific to one slider interaction.
Example builder values:
Callback Type:InlineCallback Function:
console.log('Inline callback fired for layer action');
document.body.classList.add('promo-open');
Use inline callbacks for quick tests and one-off UI reactions. For reusable site logic, use External instead.
External Callback Type
Use External when you want to call a named function that already exists in your site JavaScript.
Example builder values:
Callback Type:ExternalCallback Name:myZoroLayerCallbackCallback Args:"hello", 2, true, "#target-block"
Then define the function on the page:
function myZoroLayerCallback(message, count, enabled, selector) {
console.log(message, count, enabled, selector);
const target = document.querySelector(selector);
if (enabled && target) {
target.classList.add('is-active');
}
}
When to use External instead of Inline
Prefer External when:
- the same logic is used by multiple sliders
- the callback is longer than a few lines
- the code needs version control in your theme or plugin
- another developer needs to maintain the behavior later
Runtime Access Patterns
After a slider is embedded on a page, you may also add your own UI around it, such as custom buttons, page-level navigation, or helper scripts.
Common examples include:
- open a modal or panel when a layer is clicked
- jump to a specific slide from a custom page button
- pause or resume slider behavior from external UI
- sync page elements with slider state
The standard runtime handle is:
jQuery('#my-slider').data('zorosliderapi');
Even so, you should still verify the handle in the browser console before depending on it in production code, especially if the page has multiple sliders.
Safe Runtime Testing Workflow
Use this workflow before documenting or shipping a custom integration:
- embed the slider on a normal page using the shortcode or PHP snippet
- open browser developer tools
- confirm the target slider element and layer IDs exist
- test the custom event with a manual trigger
- test the callback output in the console
- only then connect external page controls
Embedding Matters
Preview and frontend rendering can differ if you test unsaved builder changes or if your theme adds its own styling around slider elements.
For final integration testing:
- save the slider first
- embed it on a normal WordPress page
- test both the visual result and the event or callback behavior there
If you need help embedding the slider first, see Publishing and Shortcodes.