Firstly, ❤️ this! Secondly... wish I was better at it
I'm using Locomotive scroll and Splitting.js which chunks up my text into spans, ready to animate. Great stuff. Locomotive scroll adds a is-inview class when a div is entering the viewport making it the perfect opportunity to start my GSAP animation so you get a word after a word effect as it enters the viewport.
On page load, Locomotive adds this is-inview class to everything above the fold so the animation above ^ works perfectly, However, GSAP has now run and finished so when I scroll down the page the letters don't animate in one after the other. They are just visible. You can see it's nested above .is-inview .char so whenever .is-inview is applied .char does it's thing - like it does initially on page load.
I don't want to repeat (as in once you've scrolled past it, it shouldn't animate out and in again) so the repeat option for GSAP doesn't seem right - do you know how else can I achieve this? I almost need it to keep checking to see if .is-inview is applied and then if it is, run it again to everything that hasn't already run. I just can't get my head around that part 😕 Boooo!
I saw a post on here that mentions scrollTrigger but this blows my CPU when I querySelectorAll(".char"). The page might have a lot of these spans.
Can I run my animation again if a class hasn't been added yet? (Using Locomotive Scroll & Splitting.js)
in GSAP
Posted
Firstly, ❤️ this! Secondly... wish I was better at it
I'm using Locomotive scroll and Splitting.js which chunks up my text into
spans
, ready to animate. Great stuff. Locomotive scroll adds ais-inview
class when a div is entering the viewport making it the perfect opportunity to start my GSAP animation so you get a word after a word effect as it enters the viewport.On page load, Locomotive adds this
is-inview
class to everything above the fold so the animation above ^ works perfectly, However, GSAP has now run and finished so when I scroll down the page the letters don't animate in one after the other. They are just visible. You can see it's nested above.is-inview .char
so whenever.is-inview
is applied.char
does it's thing - like it does initially on page load.I don't want to repeat (as in once you've scrolled past it, it shouldn't animate out and in again) so the repeat option for GSAP doesn't seem right - do you know how else can I achieve this? I almost need it to keep checking to see if
.is-inview
is applied and then if it is, run it again to everything that hasn't already run. I just can't get my head around that part 😕 Boooo!I saw a post on here that mentions scrollTrigger but this blows my CPU when I querySelectorAll(".char"). The page might have a lot of these spans.
A h2 on my site when all the JS has compiled for Locomotive & Splitting for example looks like this -if it's any help
Appreciate any guidance - Thanks!