Skip to content

Commit

Permalink
fix(effects): fix slide shadows flickering in Safari for Cube and Fli…
Browse files Browse the repository at this point in the history
…p effects
  • Loading branch information
nolimits4web committed Apr 20, 2022
1 parent 540a244 commit 52f5ef7
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/modules/effect-cube/effect-cube.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ export default function EffectCube({ swiper, extendParams, on }) {
on,
setTranslate,
setTransition,
shouldRecreateShadows: true,
perspective: () => true,
overwriteParams: () => ({
slidesPerView: 1,
Expand Down
1 change: 1 addition & 0 deletions src/modules/effect-flip/effect-flip.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export default function EffectFlip({ swiper, extendParams, on }) {
on,
setTranslate,
setTransition,
shouldRecreateShadows: true,
perspective: () => true,
overwriteParams: () => ({
slidesPerView: 1,
Expand Down
26 changes: 25 additions & 1 deletion src/shared/effect-init.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
export default function effectInit(params) {
const { effect, swiper, on, setTranslate, setTransition, overwriteParams, perspective } = params;
const {
effect,
swiper,
on,
setTranslate,
setTransition,
overwriteParams,
perspective,
shouldRecreateShadows,
} = params;

on('beforeInit', () => {
if (swiper.params.effect !== effect) return;
Expand All @@ -22,6 +31,21 @@ export default function effectInit(params) {
setTransition(duration);
});

const recreateShadows = () => {
swiper.slides.each((slideEl) => {
const $slideEl = swiper.$(slideEl);
$slideEl
.find(
'.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left',
)
.remove();
});
};

if (shouldRecreateShadows) {
on('transitionEnd', recreateShadows);
}

let requireUpdateOnVirtual;
on('virtualUpdate', () => {
if (swiper.params.effect !== effect) return;
Expand Down

0 comments on commit 52f5ef7

Please sign in to comment.