Skip to content

Commit

Permalink
feat(cards-effect): add perSlideRotate and perSlideOffset parameters
Browse files Browse the repository at this point in the history
fixes #5939
  • Loading branch information
nolimits4web committed Aug 12, 2022
1 parent d1f7582 commit db08a70
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/modules/effect-cards/effect-cards.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export default function EffectCards({ swiper, extendParams, on }) {
slideShadows: true,
transformEl: null,
rotate: true,
perSlideRotate: 2,
perSlideOffset: 8,
},
});

Expand All @@ -32,9 +34,9 @@ export default function EffectCards({ swiper, extendParams, on }) {
let tY = 0;
const tZ = -100 * Math.abs(progress);
let scale = 1;
let rotate = -2 * progress;
let rotate = -params.perSlideRotate * progress;

let tXAdd = 8 - Math.abs(progress) * 0.75;
let tXAdd = params.perSlideOffset - Math.abs(progress) * 0.75;

const slideIndex =
swiper.virtual && swiper.params.virtual.enabled ? swiper.virtual.from + i : i;
Expand Down
16 changes: 16 additions & 0 deletions src/types/modules/effect-cards.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,28 @@ export interface CardsEffectOptions {
* @default true
*/
slideShadows?: boolean;

/**
* Enables cards rotation
*
* @default true
*/
rotate?: boolean;

/**
* Rotate angle per slide (in degrees)
*
* @default 2
*/
perSlideRotate?: number;

/**
* Offset distance per slide (in px)
*
* @default 8
*/
perSlideOffset?: number;

/**
* CSS selector of the element inside of the slide to transform instead of the slide itself. Useful to use with cssMode
*
Expand Down

0 comments on commit db08a70

Please sign in to comment.