Jump to content
Search Community

Handling the removal and setting of SplitText with scroll smoother effects

adamatronix test
Moderator Tag

Recommended Posts

I have smoother effects applied to the SplitText plugin to create a lag effect for each character in React. But I feel the performance won't be so great on mobile so I want to be able to remove it when it hits a certain breakpoint. Is there a way to remove everything within matchMedia? 

 

React.useEffect(()=> {
let mm = gsap.matchMedia();
if(smoother) {
mm.add("(min-width: 900px)", () => {
 
const split = new SplitText("#discover-copy", { type: "words,chars" });
const chars = split.chars;
 
chars.forEach((char, i) => {
smoother.effects(char, { speed: 1, lag: (i + 1) * 0.002 });
});
 
return () => { // optional
 
};
 
})
}
},[smoother]);
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...