Skip to content

Commit

Permalink
fix(core): fix slidePrev issue in free-mode
Browse files Browse the repository at this point in the history
fixes #7869
  • Loading branch information
nolimits4web committed Jan 27, 2025
1 parent e012e34 commit a3fee36
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/core/slide/slidePrev.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ export default function slidePrev(speed, runCallbacks = true, internal) {
const normalizedTranslate = normalize(translate);
const normalizedSnapGrid = snapGrid.map((val) => normalize(val));

const isFreeMode = params.freeMode && params.freeMode.enabled;
let prevSnap = snapGrid[normalizedSnapGrid.indexOf(normalizedTranslate) - 1];
if (typeof prevSnap === 'undefined' && params.cssMode) {
if (typeof prevSnap === 'undefined' && (params.cssMode || isFreeMode)) {
let prevSnapIndex;
snapGrid.forEach((snap, snapIndex) => {
if (normalizedTranslate >= snap) {
Expand All @@ -35,7 +36,9 @@ export default function slidePrev(speed, runCallbacks = true, internal) {
}
});
if (typeof prevSnapIndex !== 'undefined') {
prevSnap = snapGrid[prevSnapIndex > 0 ? prevSnapIndex - 1 : prevSnapIndex];
prevSnap = isFreeMode
? snapGrid[prevSnapIndex]
: snapGrid[prevSnapIndex > 0 ? prevSnapIndex - 1 : prevSnapIndex];
}
}
let prevIndex = 0;
Expand Down

0 comments on commit a3fee36

Please sign in to comment.