MCPcopy Create free account
hub / github.com/electerious/basicSlider / _goto

Function _goto

src/scripts/main.js:221–236  ·  view source on GitHub ↗
(newIndex, oldIndex = c())

Source from the content-addressed store, hash-verified

219 // Use c() as the default oldIndex as the counter hasn't been recreated yet,
220 // when called through the API. Internal functions can set a custom oldIndex.
221 const _goto = (newIndex, oldIndex = c()) => {
222
223 // Run beforePrev event
224 // Stop execution when function returns false
225 if (opts.beforeChange(instance, newIndex, oldIndex) === false) return false
226
227 // Recreate counter with new initial value
228 c = counter(0, _length() - 1, newIndex)
229
230 // Switch to new slide
231 setSlide(refs.dotElems, refs.slidesElem, c(), _length())
232
233 // Run afterShow event
234 opts.afterChange(instance, newIndex, oldIndex)
235
236 }
237
238 // Navigate to the previous slide
239 const _prev = () => {

Callers 2

_prevFunction · 0.85
_nextFunction · 0.85

Calls 2

_lengthFunction · 0.85
setSlideFunction · 0.85

Tested by

no test coverage detected