DenyUA Posted September 20 Share Posted September 20 Hello! I need to disable animations when it's mobile (touch) screen. How can I do this? Link to comment Share on other sites More sharing options...
Rodrigo Posted September 20 Share Posted September 20 Hi @DenyUA and welcome to the GreenSock forums! The best alternative is to use GSAP MatchMedia: https://greensock.com/docs/v3/GSAP/gsap.matchMedia() If you want to target every touch screen (be aware that some laptops and other desktop screens do have touch events), you can use a combination of ScrollTrigger isTouch property: https://greensock.com/docs/v3/Plugins/ScrollTrigger/static.isTouch You can create your GSAP instances in a conditional block in order to create the animations when the property returns the value you're expecting. Hopefully this helps. If you keep having issues, please create a minimal demo that clearly illustrates the problem. Happy Tweening! Link to comment Share on other sites More sharing options...
GreenSock Posted September 21 Share Posted September 21 8 hours ago, Rodrigo said: If you want to target every touch screen (be aware that some laptops and other desktop screens do have touch events), you can use a combination of ScrollTrigger isTouch property Just to clarify, you can sense that directly in a matchMedia() query: "(hover: none), (pointer: coarse)" That indicates it's touch. So you can add that to any media query. Like: mm.add("(max-width: 720px) and (hover: none) and (pointer: coarse)", () => {...}) But if you're just doing conditional logic, it's totally fine to use ScrollTrigger.isTouch. Link to comment Share on other sites More sharing options...
DenyUA Posted September 21 Author Share Posted September 21 Really thank you for your help! 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