Fade
type: fade
Looping slide engine with autoplay, keyboard support, custom arrows, numbered bullets and a parallax caption layer. The chapter strip is a second slider, synced through sync.asThumbnails.
Lazy images load on demand. Artwork rides a parallax layer, while thumbnails track fractional drag progress (mode: 'progress') and act as clickable chapter selectors.
Layout types and animation flavours are independent: fade, coverflow, stack, flip and cards with staggered timing. The coverflow deliberately requests GSAP, which is not loaded here — the engine degrades to WAAPI.
type: fade
type: coverflow
type: stack
effect: flip
type: cards · stagger
Point animation.library at anime.js or Motion One and every transition is handed to that library. Switch to WAAPI or CSS to watch the fallback ladder — the slides and options stay the same; only the engine changes. Libraries load from jsDelivr on demand.
appendSlide(), prependSlide() and removeSlide() accept an HTML string, an element or a NodeList — removal also takes an index. Counts, slide labels, bullets and the active slide stay in sync, and a prepend keeps the current slide in view.
On by default: a labelled region, slide groups announced as “n of m”, a polite live region, inert + aria-hidden off-screen slides, arrow-key control while focused, and a reduced-motion path. Enable nothing; the inspector updates as you move.
The factory and the constructor return the same instance. destroy() stops timers, removes generated controls and ARIA, and restores your class, id, inline style and slide attributes, so re-initialising — or leaving the page — is clean.
Free-mode dragging, wheel input, responsive breakpoints, live update(), cancellable beforeChange, and a genuine destroy() / re-init cycle.
Install with npm install zikra-slider-pro, then call it as a factory or with new. Both return the same instance, with update(), on() and destroy() ready.
Script tag global or ES module import.
const slider = zikraslider('#hero', {
type: 'slide',
loop: true,
slidesPerView: 1,
features: { autoplay: { enabled: true } },
animation: { library: 'auto', effect: 'zoom' },
on: {
beforeChange(e) { // return false to cancel }
}
});
slider.on('afterChange', ({ index }) => console.log(index));
slider.goTo(2);
slider.destroy(); // restores the original DOM
See examples/react, examples/nextjs and examples/vue for ready-to-copy components.
// React / Next.js ('use client')
useEffect(() => {
let slider;
import('zikra-slider-pro').then(({ default: zs }) => {
slider = zs(ref.current, options);
});
return () => slider?.destroy();
}, []);
// Vue 3
onMounted(() => { instance = zikraslider(el.value, props.options); });
onBeforeUnmount(() => instance?.destroy());
Long-form guides for the decisions around the engine: picking an alternative, getting accessibility right, and keeping the bundle small.
No. GSAP, anime.js and Motion are optional. With animation.library set to 'auto', the engine uses whichever library is already loaded, then falls back to the Web Animations API and finally to CSS transitions.
No. The APIs are different, so a Swiper configuration has to be mapped option by option and re-tested. Simple sliders move quickly, but it is not a find-and-replace.
Yes. appendSlide(), prependSlide() and removeSlide() accept HTML strings, elements or arrays, and the engine renumbers data-zs-index, ids and the 'n of m' slide labels automatically.
destroy() really restore my markup?Yes. destroy() removes generated nodes and restores the original classes, ids, ARIA attributes, inline styles and the engine's data-zs-media markers, so the host matches its pre-init markup.
Yes. A React component ships as zikra-slider-pro/react, and the examples folder includes a Next.js App Router client component that destroys the instance on unmount.