Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
Brittany@Decisely

Disable/enable ScrollTrigger based on window.innerWidth and resize

Recommended Posts

I'm trying to conditionally disable ScrollTrigger on mobile, and I've read a handful of posts on this -

 

 

But I haven't had luck getting these things to work across the board on all browsers... especially Firefox. In the CodePen, I put a few things that I've tried (commented out) - .kill(), clearProps: true, .play()/.pause()... and every combination in between.

 

I know, realistically, people aren't going to be resizing their browser 50 times like I am with testing, but I don't want the site to break on them if they do.

See the Pen oNxEPdd by abitofbrit (@abitofbrit) on CodePen

Link to comment
Share on other sites

Hey Brittany. Those posts are kind of old (in terms of the short life of ScrollTrigger ;)). ScrollTrigger now has a built in method for this that makes it easy! It's .matchMedia(). You're going to love it :) 

 

Let us know if you have questions about using it and we'll be happy to do our best to help.

  • Like 2
Link to comment
Share on other sites

2 hours ago, ZachSaucier said:

Hey Brittany. Those posts are kind of old (in terms of the short life of ScrollTrigger ;)). ScrollTrigger now has a built in method for this that makes it easy! It's .matchMedia(). You're going to love it :) 

 

Let us know if you have questions about using it and we'll be happy to do our best to help.

 

Perfect. I'll look into it!

 

And yeah, the old posts are what I could find, so I was trying to adapt the new stuff with the old. Thanks again! :) 

  • Like 1
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.
×