Jump to content
Search Community

I there a way to decrease font size as a page scrolls

dgs test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Hey dgs. Welcome and thanks for being a Club GreenSock member!

 

There's a few different ways to do this sort of animation. The way that I would do it is something along the lines of this:

 

var tl = new TimelineMax({paused:true})
tl.to(".box", 1, {"scale": 0.3})

var maxDistance = 400;

window.addEventListener("scroll", function() {
  var yPos = window.scrollY;
  tl.progress(yPos / maxDistance);
});

See the Pen BaBpELw?editors=0010 by GreenSock (@GreenSock) on CodePen

 

I'm happy to explain any part of this if you're having any trouble!

  • Like 4
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...