Jump to content
Search Community

matchMedia not working

devin1229 test
Moderator Tag

Go to solution Solved by GreenSock,

Recommended Posts

I was wondering if there's anyone out there that can peep what I have to see why it's not working? 

Basically I'm just playing around and would like a box to animate to different x positions depending on the size of the window (to prevent overflow/contain the animation to the parent).

 

I'm not getting any script errors or anything, so I'm not sure what the issue is. Does matchMedia only work with advanced timelines?

See the Pen mdXdmqM by devin1229 (@devin1229) on CodePen

Link to comment
Share on other sites

  • Solution

The main problem is a typo - you had a lowercase "s" in ScrollTrigger.create(...)

// BAD
scrollTrigger.matchMedia(...)
                         
// GOOD
ScrollTrigger.matchMedia(...)

 

:)

 

Beware that the way you set things up with your media queries, if the viewport is between 600px and 959px, neither animation will run. 

 

I hope that helps.

  • Like 1
Link to comment
Share on other sites

16 hours ago, GreenSock said:

The main problem is a typo - you had a lowercase "s" in ScrollTrigger.create(...)

// BAD
scrollTrigger.matchMedia(...)
                         
// GOOD
ScrollTrigger.matchMedia(...)

 

:)

 

Beware that the way you set things up with your media queries, if the viewport is between 600px and 959px, neither animation will run. 

 

I hope that helps.

 

Hahaha... it was late!

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