Я знаю, что что-то упускаю с вращением внутренней обложки, когда книга «нажимается на», чтобы открыть, но я не вижу ее. Напоминает фон задней обложки. < /li>
Внутренняя обложка отображается как сплошная обложка, которая соответствует цвету фона передней обложки.
Я знаю, что что-то упускаю с вращением внутренней обложки, когда книга «нажимается на», чтобы открыть, но я не вижу ее. Напоминает фон задней обложки. < /li> Внутренняя обложка отображается как сплошная обложка, которая соответствует цвету фона передней обложки.[code]
Opening Book with GSAP
body { font-family: 'Inter', sans-serif; background-color: #f0f4f8; overflow: hidden; }
/* The scene is the 3D space for the book */ .scene { display: flex; align-items: center; justify-content: center; height: 100vh; perspective: 2500px; }
/* The wrapper handles positioning and can be clicked */ .book-wrapper { position: relative; cursor: pointer; }
/* The book container holds all the 3D pieces */ .book { width: 350px; height: 500px; position: relative; transform-style: preserve-3d; }
/* The front cover, which will flip open */ .front-cover { position: absolute; width: 100%; height: 100%; top: 0; left: 0; transform-origin: left center; transform-style: preserve-3d; z-index: 10; }
// Select the elements to animate const bookWrapper = document.getElementById('book-wrapper'); const frontCover = document.querySelector('.front-cover'); const flippingPages = gsap.utils.toArray('.flipping-page');
// Set the default transform origin for the cover and pages gsap.set([frontCover, flippingPages], { transformOrigin: "left center" });
// Create a GSAP timeline, paused by default const timeline = gsap.timeline({ paused: true });
// Add animations to the timeline timeline // 1. Move the entire book wrapper to the right to center the spine .to(bookWrapper, { x: 175, duration: 1.2, ease: "power2.inOut" }) // 2. Flip the cover open at the same time .to(frontCover, { rotationY: -180, duration: 1.2, ease: "power2.inOut" }, " < /p>