Jump to content
Search Community

How do I disable GSAP animations on mobile screen?

DenyUA test
Moderator Tag

Recommended Posts

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

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

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...