Hector18 Posted June 6, 2022 Share Posted June 6, 2022 Hi, I have this function: $('.stagger-caption').each(function(){ var $this = $(this); var $totalHeight = $this.closest('.stagger-slide').outerHeight(true) - $this.outerHeight(true); const ST= ScrollTrigger.create({ trigger: $this, start: "top top", end: "+=" + $totalHeight, pin: $this, scrub: true, invalidateOnRefresh: true }); }); How can I update the END value on resize? Thank you! Link to comment Share on other sites More sharing options...
Cassie Posted June 6, 2022 Share Posted June 6, 2022 Hi there! So the start and end values get recalculated automatically on resize, but your variable doesn't. You can fix this by popping your calculation into a functional value, then when your scrollTrigger refreshes it will run that code again. ScrollTrigger.create({ trigger: $this, start: "top top", end: () => `+=${$this.closest('.stagger-slide').outerHeight(true) - $this.outerHeight(true)}`, pin: $this, scrub: true, invalidateOnRefresh: true }); Hope this helps! 2 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now