Skip to content

Commit 980c4c7

Browse files
committed
feat(creative-effect): add shadowPerProgress parameter
1 parent 0c30f5c commit 980c4c7

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/modules/effect-creative/effect-creative.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export default function EffectCreative({ swiper, extendParams, on }) {
88
creativeEffect: {
99
transformEl: null,
1010
limitProgress: 1,
11+
shadowPerProgress: false,
1112
progressMultiplier: 1,
1213
perspective: true,
1314
prev: {
@@ -94,7 +95,10 @@ export default function EffectCreative({ swiper, extendParams, on }) {
9495
$shadowEl = createShadow(params, $slideEl);
9596
}
9697
if ($shadowEl.length) {
97-
$shadowEl[0].style.opacity = Math.min(Math.max(Math.abs(progress), 0), 1);
98+
const shadowOpacity = params.shadowPerProgress
99+
? progress * (1 / params.limitProgress)
100+
: progress;
101+
$shadowEl[0].style.opacity = Math.min(Math.max(Math.abs(shadowOpacity), 0), 1);
98102
}
99103
}
100104

src/types/modules/effect-creative.d.ts

+6
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ export interface CreativeEffectOptions {
7272
* @default 1
7373
*/
7474
limitProgress?: number;
75+
/**
76+
* Splits shadow "opacity" per slide based on `limitProgress` (only if transformation shadows enabled). E.g. setting `limitProgress: 2` and enabling `shadowPerProgress`, will set shadow opacity to `0.5` and `1` on two slides next to active. With this parameter disabled, all slides beside active will have shadow with `1` opacity
77+
*
78+
* @default false
79+
*/
80+
shadowPerProgress?: boolean;
7581
/**
7682
* Allows to multiply slides transformations and opacity.
7783
*

0 commit comments

Comments
 (0)