jored Posted October 18, 2023 Share Posted October 18, 2023 Hello guys, I am currently creating a scroll-triggered animation on desktop, and I have no issues. However, it is stuttering on mobile. Do you have any ideas? Thanks you See the Pen jOXgyjX by jordan-morand (@jordan-morand) on CodePen Link to comment Share on other sites More sharing options...
GreenSock Posted October 18, 2023 Share Posted October 18, 2023 Have you tried any of these?: ScrollTrigger.config({ ignoreMobileResize: true }); ScrollTrigger.normalizeScroll(true); Link to comment Share on other sites More sharing options...
jored Posted October 18, 2023 Author Share Posted October 18, 2023 I solved like that but I am not sure that it is the best practice if someone has a better idea: Quote gsap.registerPlugin(ScrollTrigger); let tl = null; let mm = gsap.matchMedia(); mm.add("(min-width: 768px)", () => { tl = gsap.timeline({ scrollTrigger: { trigger: ".scene", start: "top 3%", end: "bottom -100%", scrub: 1.5, pin: true }, }); }); mm.add("(max-width: 768px)", () => { tl = gsap.timeline({ scrollTrigger: { trigger: ".scene", start: "top 3%", end: "+=1000", scrub: 1, pin: '.viewer', toggleActions: "play none none reverse", }, }); }); Link to comment Share on other sites More sharing options...
Rodrigo Posted October 18, 2023 Share Posted October 18, 2023 Hi, That looks good to me. Without knowing the rest of your code, I don't think there's really any upside in creating a variable for the timeline, unless you need that reference later in your code. Happy Tweening! Link to comment Share on other sites More sharing options...
Farhannn Posted October 22, 2023 Share Posted October 22, 2023 @joredwhere did u put the scroll trigger config code Link to comment Share on other sites More sharing options...
jored Posted October 22, 2023 Author Share Posted October 22, 2023 @Farhannn in my first post, the codepen is updated. You can look, the code is OK. 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now