| 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 = () => { |