From d2136b34b029beedd4c0da410b5b261233e432a1 Mon Sep 17 00:00:00 2001 From: Hamza Mubin Date: Thu, 7 Nov 2024 14:24:56 +0530 Subject: [PATCH] added gsap to each product --- gsap.js | 42 ++++++++++++++++++++++++++++++++++++++++++ index.html | 10 +++++++--- package-lock.json | 6 ++++++ style.css | 2 ++ 4 files changed, 57 insertions(+), 3 deletions(-) create mode 100644 gsap.js create mode 100644 package-lock.json diff --git a/gsap.js b/gsap.js new file mode 100644 index 00000000..9db93976 --- /dev/null +++ b/gsap.js @@ -0,0 +1,42 @@ +gsap.registerPlugin(ScrollTrigger); + +// Select all product containers +document.querySelectorAll(".col-2").forEach((product) => { + + + gsap.fromTo( + product.querySelector(".color-box"), + { rotation: 90,opacity:0 }, + { + opacity:1, + rotation: 0, + duration:0.3, + ease: "power2.out", + scrollTrigger: { + trigger: product, + start: "top 80%", + end: "top 70%", + + scrub: true + } + } + ); + + // Animation for the controller image in each product + gsap.fromTo( + product.querySelector(".controller"), + { scale: 0.1, opacity: 0, }, // Initial state + { + scale: 1, + opacity: 1, + duration: 0.3, + ease: "back.out(1.7)", + scrollTrigger: { + trigger: product, + start: "top 80%", // Customize to control when each product animates + end: "top 70%", + scrub: true + } + } + ); +}); diff --git a/index.html b/index.html index 7900891d..c62bef01 100644 --- a/index.html +++ b/index.html @@ -417,6 +417,10 @@

Ergonomic Gaming Chair

+ + + +

Our Most Loved Products

@@ -638,9 +642,9 @@

Contact Our Customer Support Team

- - -