Jump to content
Search Community

ScrollTrigger.matchMedia functional for gsap.timeline

_Greg _ test
Moderator Tag

Recommended Posts

Hi!

Does it have somehing like ScrollTrigger.matchMedia functional but for gsap.timeline somethinkg like:

 

let tl = gsap.timeline()



tl.matchMedia({
 // desktop
  "(min-width: 800px)": function() {
    tl.to(el, {x: 100})
  },
  // mobile
  "(max-width: 799px)": function() {
    tl.to(el, {y: 400, autoAlpha: 0}) // other animation for mobile
  },
  // all 
  "all": function() {
    tl.to(el, {scale: 2})
  }
})

How better create something like this with gsap.timeline?

Link to comment
Share on other sites

Hey Nekiy2. You can use regular matchMedia functions for this sort of thing. However, they won't switch out tweens within timelines.

 

How about you create a minimal demo showing the sort of thing that you're trying to do and then we can help out with how we might approach it?

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