Skip to content

Commit

Permalink
fix(core): fix cssMode animation in Safari 14
Browse files Browse the repository at this point in the history
fixes #4925
  • Loading branch information
nolimits4web committed Sep 8, 2021
1 parent e80925e commit 7fd04fe
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/shared/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,21 @@ function animateCSSModeScroll({ swiper, targetPosition, side }) {
const easeProgress = 0.5 - Math.cos(progress * Math.PI) / 2;
let currentPosition = startPosition + easeProgress * (targetPosition - startPosition);

if (isOutOfBound(currentPosition, targetPosition)) currentPosition = targetPosition;
if (isOutOfBound(currentPosition, targetPosition)) {
currentPosition = targetPosition;
}
swiper.wrapperEl.scrollTo({
[side]: currentPosition,
});
if (isOutOfBound(currentPosition, targetPosition)) {
swiper.wrapperEl.style.overflow = 'hidden';
swiper.wrapperEl.style.scrollSnapType = '';
setTimeout(() => {
swiper.wrapperEl.style.overflow = '';
swiper.wrapperEl.scrollTo({
[side]: currentPosition,
});
});
window.cancelAnimationFrame(swiper.cssModeFrameID);
return;
}
Expand Down

0 comments on commit 7fd04fe

Please sign in to comment.