Jump to content
Search Community

matchMedia() not working as expected

M. Adnan Ghori test
Moderator Tag

Go to solution Solved by mvaneijgen,

Recommended Posts

  • Solution

I would strongly encourage the use of markers: true, this way you can see what ScrollTrigger is doing and thus see if that is inline with your assumptions. 

 

Having end: "bottom center" on small screens will probably mean that the ScrollTrigger is already at the end when it has not even started, so nothing will happen of at least your animation will jump to the end. 

 

Also you're media queries overlap, max with 320px is inside 1920px, usually you do something like this, where when one media query ends the other takes over.

mm.add("(min-width: 800px)", () => {
  // desktop setup code here...
});

mm.add("(max-width: 799px)", () => {
  // mobile setup code here...
});

// or write it all the way out 
"(min-width: 371px) and (max-width: 1920px)"

 

Keep in mind that ScrollTrigger.matchMedia() has ben depricated (https://gsap.com/docs/v3/Plugins/ScrollTrigger/static.matchMedia()), it is now build in to GSAP https://gsap.com/docs/v3/GSAP/gsap.matchMedia()

 

Hope it helps and happy tweening! 

 

See the Pen zYeWzxW?editors=0010 by mvaneijgen (@mvaneijgen) on CodePen

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