Options, API and events

What a slider is given, what it can be asked, and what it says.

Options

Of the core:

OptionDefault
perViewfrom CSSSlides per view, fractions allowed; 'auto' takes each slide's own width
gapfrom CSSpx
axis'x''y': downwards
loopfalseNeeds more slides than fit in the view, plus one
align'start''center', 'end'
group1Slides per step
containtrueNo empty space at the ends
freefalseRest anywhere, glide on after a drag
duration600ms of a move
easecurve of a move to a slide, u => … from 0 to 1 in duration, instead of the spring; a drag let go keeps the spring
start0First slide
dragtrue
onListeners by the name of their event: { change: ( index ) => … }
plugins[]See Plugins that come with it

Of gpuslider/full, and of data-gs, also:

OptionDefaultIs the plugin
mode'row''stack': stack()
autoHeightfalseautoHeight()
autoplay0ms per slide: autoplay()
keyboard, wheeltruekeyboard(), wheel()
prev, next, pause, dotsControls anywhere on the page: an element, several, or a selector

API

next(), prev()
to( index, { instant } )To a snap
toSlide( index, { instant } )To the snap of a slide, when a snap has several
index, previous, count()Snaps
canNext, canPrevWhether there is a snap to go to
progress0 to 1 through the slides
visible()Indexes of the slides in view
restingNothing moves, nothing is drawn
set( options )Changes options of the slider that exists
update()Measures again, after a change the slider cannot see
use( plugin )Adds a plugin later
pluginsThe plugins by their name: slider.plugins.lightbox.open( 2 )
on( name, fn ), once( name, fn )Both return a function that removes the listener
off( name, fn ), emit( name, detail )
grab(), drag( position ), release( velocity )Move it as a pointer does
shift( by, push )Moves it and where it is going by the same distance; as a push it counts as speed
wake()Asks for a frame
root, track, slides, options, layout(), motion, view, win, signalFor plugins. signal ends with the slider: what listens with it needs no removing
destroy()Gives the page back as it was

Slides that are added to the track or removed from it are seen by the slider: render them with whatever renders your page.

Events

Listeners get what the event says, then the slider.

slider.on( 'change', ( index, slider ) => {} );
slider.on( '*', ( name, detail, slider ) => {} );
EventSays
readyThe slider. After the listeners that are added right after createSlider()
changeIndex of the snap the slider goes to
settleIndex of the snap it came to rest at. Also after the slider was measured, when it has not moved
visibleIndexes of the slides in view, when they change
dragstart, dragendThe motion; the velocity it was let go with
click{ index, event }. Not the click that ends a drag; a drag of 10 px or less is a click, as a hand that clicks moves a little. A click on a slider that moves holds it, and is a click on the slide under it. The slide is the one that is seen: see Effects
measureThe layout, after every measuring
slidesThe slides, after some were added or removed
frameThe view, on every frame of a move
destroyThe slider
autoplay:play, autoplay:pause
autoplay:run, autoplay:wait{ delay, left } when the time of a slide begins to run, left of delay; nothing when it stops before its end
marquee:play, marquee:pause
canvas:readycanvas() has chosen its layer: 'gpu' or 'gl'
gpu:on, gpu:off, gl:on, gl:offThe canvas took over, or gave the slides back to the page
loading:start, loading:progress, loading:doneloading(): how many media there are, how many of them are there, and that all are
lightbox:open, lightbox:closeIndex of the slide

Whether the slider is at an end: canNext and canPrev, at change.