-
Notifications
You must be signed in to change notification settings - Fork 0
/
pg1.js
51 lines (43 loc) · 1.35 KB
/
pg1.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
const scroller = new LocomotiveScroll({
el: document.querySelector("[data-scroll-container]"),
smooth: true,
});
gsap.registerPlugin(Flip);
CustomEase.create("cubic", "0.83. 0, 0.17, 1");
const gallery = document.querySelector(".img-gallery-container");
const images = gsap.utils.toArray(".img");
let rotationValues = [10, -5, 2, -2];
let isFlipped = false;
function apllyRotation() {
images.forEach((img, index) => {
const rotation = isFlipped ? 0 : rotationValues[index];
gsap.to(img, {
rotate: rotation,
duration: 2,
ease: "cubic",
delay: 0.155,
});
});
}
document.querySelector(".btn").addEventListener("click", () => {
isFlipped != isFlipped;
setTimeout(() => {
document.querySelector(".btn").textContent = isFlipped ? "Hide All Ideas" : "Explore Ideas";
}, 1000)
let state = Flip.getState(".img-gallery-container, .img");
gallery.classList.toggle("order");
images.forEach((img) => img.classList.toggle("reorder"));
Flip.from(state, {
absolute: true,
duration: 2,
rotate: 0,
stagger: 0.05,
ease: "cubic",
onStart: () => {
applyRotation();
},
onComplete: () => {
scroller.update();
},
});
});