Last active
May 12, 2021 21:03
-
-
Save rhcarlosweb/7dd9febb0918b01333fa9cc5853ad2ea to your computer and use it in GitHub Desktop.
new animations with gsap 3
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
import gsap from "gsap" | |
import ScrollTrigger from "gsap/ScrollTrigger" | |
gsap.registerPlugin(ScrollTrigger) | |
const fadeIn = document.querySelectorAll(".fade-in") | |
if (fadeIn) { | |
fadeIn.forEach(value => { | |
const $delay = value.getAttribute("data-delay") ? value.getAttribute("data-delay") : 0 | |
gsap.fromTo(value, { | |
autoAlpha: 0, | |
}, { | |
autoAlpha : 1, | |
ease : "power1.inOut", | |
duration : 1.5, | |
delay : $delay, | |
scrollTrigger: { | |
trigger : value, | |
start : "top 90%", | |
toggleActions: "play none none none" | |
} | |
}) | |
}) | |
} | |
const fadeInLeft = document.querySelectorAll(".fade-in-left") | |
if (fadeInLeft) { | |
fadeInLeft.forEach(value => { | |
const $delay = value.getAttribute("data-delay") ? value.getAttribute("data-delay") : 0 | |
gsap.fromTo(value, { | |
autoAlpha: 0, | |
x : "-=30", | |
}, { | |
autoAlpha : 1, | |
x : "+=30", | |
ease : "power1.inOut", | |
duration : 1.5, | |
delay : $delay, | |
scrollTrigger: { | |
trigger : value, | |
start : "top 90%", | |
toggleActions: "play none none none" | |
} | |
}) | |
}) | |
} | |
const fadeInRight = document.querySelectorAll(".fade-in-right") | |
if (fadeInRight) { | |
fadeInRight.forEach(value => { | |
const $delay = value.getAttribute("data-delay") ? value.getAttribute("data-delay") : 0 | |
gsap.fromTo(value, { | |
autoAlpha: 0, | |
x : "+=30", | |
}, { | |
autoAlpha : 1, | |
x : "-=30", | |
ease : "power1.inOut", | |
duration : 1.5, | |
delay : $delay, | |
scrollTrigger: { | |
trigger : value, | |
start : "top 90%", | |
toggleActions: "play none none none" | |
} | |
}) | |
}) | |
} | |
const fadeInDown = document.querySelectorAll(".fade-in-down") | |
if (fadeInDown) { | |
fadeInDown.forEach(value => { | |
const $delay = value.getAttribute("data-delay") ? value.getAttribute("data-delay") : 0 | |
gsap.fromTo(value, { | |
autoAlpha: 0, | |
y : "-=30" | |
}, { | |
autoAlpha : 1, | |
y : "+=30", | |
ease : "power1.inOut", | |
duration : 1.5, | |
delay : $delay, | |
scrollTrigger: { | |
trigger : value, | |
start : "top 90%", | |
toggleActions: "play none none none" | |
} | |
}) | |
}) | |
} | |
const fadeInUp = document.querySelectorAll(".fade-in-up") | |
if (fadeInUp) { | |
fadeInUp.forEach(value => { | |
const $delay = value.getAttribute("data-delay") ? value.getAttribute("data-delay") : 0 | |
gsap.fromTo(value, { | |
autoAlpha: 0, | |
y : "+=30", | |
}, { | |
autoAlpha : 1, | |
y : "-=30", | |
ease : "power1.inOut", | |
duration : 1.5, | |
delay : $delay, | |
scrollTrigger: { | |
trigger : value, | |
start : "top 90%", | |
toggleActions: "play none none none" | |
} | |
}) | |
}) | |
} | |
const revealTexts = document.querySelectorAll(".reveal-text") | |
if (revealTexts) { | |
revealTexts.forEach(value => { | |
const $text = value.querySelector(".reveal") | |
gsap.to($text, { | |
duration : 1, | |
y : 0, | |
ease : "sine.out", | |
scrollTrigger: { | |
trigger : value, | |
start : "top 80%", | |
toggleActions: "play none none none" | |
} | |
}) | |
}) | |
} |
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
.fade-in, .fade-in-left, .fade-in-right, .fade-in-up, .fade-in-down { | |
opacity: 0; | |
visibility: hidden; | |
} | |
.reveal-text { | |
position: relative; | |
overflow: hidden; | |
.reveal { | |
display: inline-block; | |
transform: translateY(100%); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment