diff --git a/src/core/slide/slideNext.mjs b/src/core/slide/slideNext.mjs index 0a2616adf..89a0f21e7 100644 --- a/src/core/slide/slideNext.mjs +++ b/src/core/slide/slideNext.mjs @@ -1,8 +1,11 @@ /* eslint no-unused-vars: "off" */ -export default function slideNext(speed = this.params.speed, runCallbacks = true, internal) { +export default function slideNext(speed, runCallbacks = true, internal) { const swiper = this; const { enabled, params, animating } = swiper; if (!enabled || swiper.destroyed) return swiper; + if (typeof speed === 'undefined') { + speed = swiper.params.speed; + } let perGroup = params.slidesPerGroup; if (params.slidesPerView === 'auto' && params.slidesPerGroup === 1 && params.slidesPerGroupAuto) { perGroup = Math.max(swiper.slidesPerViewDynamic('current', true), 1); diff --git a/src/core/slide/slidePrev.mjs b/src/core/slide/slidePrev.mjs index cfeac4540..46f972fea 100644 --- a/src/core/slide/slidePrev.mjs +++ b/src/core/slide/slidePrev.mjs @@ -1,8 +1,12 @@ /* eslint no-unused-vars: "off" */ -export default function slidePrev(speed = this.params.speed, runCallbacks = true, internal) { +export default function slidePrev(speed, runCallbacks = true, internal) { const swiper = this; const { params, snapGrid, slidesGrid, rtlTranslate, enabled, animating } = swiper; if (!enabled || swiper.destroyed) return swiper; + if (typeof speed === 'undefined') { + speed = swiper.params.speed; + } + const isVirtual = swiper.virtual && params.virtual.enabled; if (params.loop) { diff --git a/src/core/slide/slideReset.mjs b/src/core/slide/slideReset.mjs index 52974b655..981da42cc 100644 --- a/src/core/slide/slideReset.mjs +++ b/src/core/slide/slideReset.mjs @@ -1,6 +1,9 @@ /* eslint no-unused-vars: "off" */ -export default function slideReset(speed = this.params.speed, runCallbacks = true, internal) { +export default function slideReset(speed, runCallbacks = true, internal) { const swiper = this; if (swiper.destroyed) return; + if (typeof speed === 'undefined') { + speed = swiper.params.speed; + } return swiper.slideTo(swiper.activeIndex, speed, runCallbacks, internal); } diff --git a/src/core/slide/slideTo.mjs b/src/core/slide/slideTo.mjs index 937fff202..133d295bb 100644 --- a/src/core/slide/slideTo.mjs +++ b/src/core/slide/slideTo.mjs @@ -1,12 +1,6 @@ import { animateCSSModeScroll } from '../../shared/utils.mjs'; -export default function slideTo( - index = 0, - speed = this.params.speed, - runCallbacks = true, - internal, - initial, -) { +export default function slideTo(index = 0, speed, runCallbacks = true, internal, initial) { if (typeof index === 'string') { index = parseInt(index, 10); } @@ -28,12 +22,15 @@ export default function slideTo( } = swiper; if ( - (swiper.animating && params.preventInteractionOnTransition) || (!enabled && !internal && !initial) || - swiper.destroyed + swiper.destroyed || + (swiper.animating && params.preventInteractionOnTransition) ) { return false; } + if (typeof speed === 'undefined') { + speed = swiper.params.speed; + } const skip = Math.min(swiper.params.slidesPerGroupSkip, slideIndex); let snapIndex = skip + Math.floor((slideIndex - skip) / swiper.params.slidesPerGroup); diff --git a/src/core/slide/slideToClosest.mjs b/src/core/slide/slideToClosest.mjs index fe427a54c..5082d97c4 100644 --- a/src/core/slide/slideToClosest.mjs +++ b/src/core/slide/slideToClosest.mjs @@ -1,12 +1,12 @@ /* eslint no-unused-vars: "off" */ -export default function slideToClosest( - speed = this.params.speed, - runCallbacks = true, - internal, - threshold = 0.5, -) { +export default function slideToClosest(speed, runCallbacks = true, internal, threshold = 0.5) { const swiper = this; if (swiper.destroyed) return; + + if (typeof speed === 'undefined') { + speed = swiper.params.speed; + } + let index = swiper.activeIndex; const skip = Math.min(swiper.params.slidesPerGroupSkip, index); const snapIndex = skip + Math.floor((index - skip) / swiper.params.slidesPerGroup); diff --git a/src/core/slide/slideToLoop.mjs b/src/core/slide/slideToLoop.mjs index e20e713e1..864ca3153 100644 --- a/src/core/slide/slideToLoop.mjs +++ b/src/core/slide/slideToLoop.mjs @@ -1,9 +1,4 @@ -export default function slideToLoop( - index = 0, - speed = this.params.speed, - runCallbacks = true, - internal, -) { +export default function slideToLoop(index = 0, speed, runCallbacks = true, internal) { if (typeof index === 'string') { const indexAsNumber = parseInt(index, 10); @@ -11,6 +6,11 @@ export default function slideToLoop( } const swiper = this; if (swiper.destroyed) return; + + if (typeof speed === 'undefined') { + speed = swiper.params.speed; + } + const gridEnabled = swiper.grid && swiper.params.grid && swiper.params.grid.rows > 1; let newIndex = index; if (swiper.params.loop) {