-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
created animation for the box-contents
- Loading branch information
Janette Gadol
authored and
Janette Gadol
committed
Sep 26, 2023
1 parent
9cfa98b
commit 8b0006e
Showing
7 changed files
with
200 additions
and
101 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
dist/assets/index-10b89392.css → dist/assets/index-91e5d634.css
Large diffs are not rendered by default.
Oops, something went wrong.
182 changes: 91 additions & 91 deletions
182
dist/assets/index-306cfb0a.js → dist/assets/index-e93ca72b.js
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import gsap from "gsap"; | ||
import { ScrollTrigger } from "gsap/all"; | ||
// import VanillaTilt from "vanilla-tilt"; | ||
|
||
const boxContentsAnimation = () => { | ||
gsap.registerPlugin(ScrollTrigger); | ||
|
||
let mm = gsap.matchMedia(); | ||
|
||
const boxContent = gsap.utils.toArray( | ||
".box-contents-container .contents-container" | ||
); | ||
|
||
mm.add("(min-width: 999.1px)", () => { | ||
boxContent.forEach((content) => { | ||
const boxImg = gsap.utils.toArray(content.querySelector("img")); | ||
|
||
boxImg.forEach((img) => { | ||
gsap.set(img, { | ||
y: "-150%", | ||
transition: "transform 1.5s ease-in-out", | ||
}); | ||
|
||
gsap.to(img, { | ||
y: 0, | ||
scrollTrigger: { | ||
trigger: img, | ||
start: "top 85%", | ||
scrub: true, | ||
}, | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
mm.add("(max-width: 999px)", () => { | ||
const boxImg1 = document.querySelector( | ||
".box-contents-container .contents-container img[alt='iPhone 15 Pro']" | ||
); | ||
const boxImg2 = document.querySelector( | ||
".box-contents-container .contents-container img[alt='USB-C Charger Cable']" | ||
); | ||
|
||
gsap.set(boxImg1, { x: "-150%", autoAlpha: 0 }); | ||
gsap.set(boxImg2, { x: "150%", autoAlpha: 0 }); | ||
|
||
gsap.to(boxImg1, { | ||
x: 0, | ||
autoAlpha: 1, | ||
duration: 1.5, | ||
scrollTrigger: { | ||
trigger: boxImg1, | ||
start: "top 90%", | ||
end: "top 75%", | ||
once: true, | ||
}, | ||
}); | ||
gsap.to(boxImg2, { | ||
x: 0, | ||
autoAlpha: 1, | ||
duration: 1.5, | ||
scrollTrigger: { | ||
trigger: boxImg2, | ||
start: "top 90%", | ||
end: "top 75%", | ||
once: true, | ||
}, | ||
}); | ||
}); | ||
}; | ||
|
||
export default boxContentsAnimation; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters