Hi,
I have a card flipping animation working perfectly everywhere apart from mobile Safari. In that browser, as the card flips it half disappears. I think this is due to one of the parent elements having a white background, and my card is rotating below that if that makes sense. At the end of the animation the whole card is visible again.
This is my code:
gsap.utils.toArray(".card-wrapper").forEach(function(card) {
gsap.set(card, {
transformStyle: "preserve-3d",
transformPerspective: 1000
});
const q = gsap.utils.selector(card);
const front = q(".front");
const back = q(".back");
gsap.set(back, { rotationY:-180 });
const tl = gsap.timeline({ paused: true })
.to(front, { duration: 1, rotationY: 180 })
.to(back, { duration: 1, rotationY: 0, rotationZ: "random(-6, 6)" }, 0)
.to(card, { z: 50 }, 0)
.to(card, { z: 0 }, 0.5)
tl.reverse();
card.addEventListener("click", function() {
tl.reversed() ? tl.play() : tl.reverse();
});
});
I think what I need to do is lift the whole thing up on the z axis, so when it spins with rotationY it doesn't intersect with what is below it. I am not sure how to do this without it affecting the perspective, which is looking really nice when it spins.