Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
plastois

(scrollTrigger) update animated value on onRefresh

Go to solution Solved by ZachSaucier,

Recommended Posts

Hello!

 

I searched docs and forums but i can't find answer for my problem. I have ScrollTrigger animation, where xPercent is a variable. I want change it on refresh, like this:

gsap.to(".class", {
				scrollTrigger: {
					trigger: parent_trigger,
					pin: true,
					start: "top top",
					markers: true,
					scrub: 1,
					invalidateOnRefresh: true,
					snap: {
						snapTo: 1 / 200,
						duration: {min: 0.2, max: 0.3},
						delay: 0
					},
					onRefresh: () => {
						let scroll_width = 100 - ($(window).width()*100 / width);
						xPercent: -scroll_width
					},
				},
				xPercent: -scroll_width,
				ease: "none",
			});

Is there any way to archive my goal?

Link to comment
Share on other sites

  • Solution

Hey plastois. You just need to make sure xPercent has a functional value:

xPercent: () => -scroll_width

 

  • Like 2
  • Thanks 1
Link to comment
Share on other sites

Thanks! I totally forgot about functional values! I also put all calculations inside xPercent function instead of onRefresh, it works better

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