Jump to content
Search Community

Refresh on resize of scrollTrigger from to values

tobihardatwork test
Moderator Tag

Go to solution Solved by mvaneijgen,

Recommended Posts

Hey folks,

I'm currently stuck on an implementation detail with the scrollTrigger. 

What I want to do:
1. Text size decreases when scrolling down, and increases when scrolling up.
2. Text size start and end values depend on viewport width (mobile, tablet ( from 768px), desktop (from 1440px))
3. Text size (initial and end size) gets recalculated and refreshed when viewport size changes and goes from one viewport zone into another (for ex. desktop -> tablet)

What I have:
1. Works
2. Works
3. Does not work. I tried to implement this functionality with a combination of
- { fontSize: () => initialFontSize }
- invalidateOnRefresh: true
- window.addEventListener("resize", function () { ...   ScrollTrigger.refresh();   });

I've tried various versions of this combination but did not succeed. I am grateful for any hints :)
I tried to simplify it and put it in a codepen (attached). 


See the Pen oNJwzwp by pinkpantheratwork (@pinkpantheratwork) on CodePen

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