Skip to content

Commit

Permalink
fix(effect-cards): fixed in RTL mode
Browse files Browse the repository at this point in the history
fixes #5534
  • Loading branch information
nolimits4web committed Jun 7, 2023
1 parent 8b4cccd commit e402f05
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/modules/effect-cards/effect-cards.js
Expand Up @@ -15,10 +15,10 @@ export default function EffectCards({ swiper, extendParams, on }) {
});

const setTranslate = () => {
const { slides, activeIndex } = swiper;
const { slides, activeIndex, rtlTranslate: rtl } = swiper;
const params = swiper.params.cardsEffect;
const { startTranslate, isTouched } = swiper.touchEventsData;
const currentTranslate = swiper.translate;
const currentTranslate = rtl ? -swiper.translate : swiper.translate;
for (let i = 0; i < slides.length; i += 1) {
const slideEl = slides[i];
const slideProgress = slideEl.progress;
Expand Down Expand Up @@ -61,13 +61,12 @@ export default function EffectCards({ swiper, extendParams, on }) {
tXAdd += 96 * subProgress;
tY = `${-25 * subProgress * Math.abs(progress)}%`;
}

if (progress < 0) {
// next
tX = `calc(${tX}px + (${tXAdd * Math.abs(progress)}%))`;
tX = `calc(${tX}px ${rtl ? '-' : '+'} (${tXAdd * Math.abs(progress)}%))`;
} else if (progress > 0) {
// prev
tX = `calc(${tX}px + (-${tXAdd * Math.abs(progress)}%))`;
tX = `calc(${tX}px ${rtl ? '-' : '+'} (-${tXAdd * Math.abs(progress)}%))`;
} else {
tX = `${tX}px`;
}
Expand All @@ -80,11 +79,13 @@ export default function EffectCards({ swiper, extendParams, on }) {
const scaleString =
progress < 0 ? `${1 + (1 - scale) * progress}` : `${1 - (1 - scale) * progress}`;

/* eslint-disable */
const transform = `
translate3d(${tX}, ${tY}, ${tZ}px)
rotateZ(${params.rotate ? rotate : 0}deg)
rotateZ(${params.rotate ? (rtl ? -rotate : rotate) : 0}deg)
scale(${scaleString})
`;
/* eslint-enable */

if (params.slideShadows) {
// Set shadows
Expand Down

0 comments on commit e402f05

Please sign in to comment.