Jump to content
Search Community

Resizing the window doesn't change the animation measures

pepethefroggg test
Moderator Tag

Go to solution Solved by OSUblake,

Recommended Posts

Hello! 

 

I'm having trouble making an animation responsive, as I can't find a way to update the x value.

I tried also to refresh the scrolltrigger onresize but it didn't work.

So what i want to obtain is my square getting in the middle of the vw even after I resize the window, is it possible?

See the Pen eYWgQPN by pepethefroggg (@pepethefroggg) on CodePen

Link to comment
Share on other sites

  • Solution

Try this.

 

gsap.to(".box", {
  scrollTrigger: {
    trigger: ".box",
    start: "top center",
    end: "top center",
    toggleActions: "play none reverse none",
    markers: true,
    invalidateOnRefresh: true
  },
  ease: "power2.out",
  x: setWidth,
  duration:1.5,
})

 

Invalidate on refresh will call any functions again.

 

This just sets the value.

x: setWidth()

 

This is a reference to a function that will get called.

x: setWidth

 

  • Like 4
Link to comment
Share on other sites

16 minutes ago, OSUblake said:

Try this.

 


gsap.to(".box", {
  scrollTrigger: {
    trigger: ".box",
    start: "top center",
    end: "top center",
    toggleActions: "play none reverse none",
    markers: true,
    invalidateOnRefresh: true
  },
  ease: "power2.out",
  x: setWidth,
  duration:1.5,
})

 

Invalidate on refresh will call any functions again.

 

This just sets the value.


x: setWidth()

 

This is a reference to a function that will get called.


x: setWidth

 

Thank you so much! This was really really helpful

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