Jump to content

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

Move element at center and expand it as user scroll down

Recommended Posts

Hello everyone, I am fairly new with GSAP and ScrollTrigger as well. What I want is I have a div with some  text in it I want to center it as user scroll it and later when it is center I want to expand it's height and width to cover whole viewport.

See the Pen JjXqMaR by midnightgamer (@midnightgamer) on CodePen

Link to comment
Share on other sites

1 hour ago, mikel said:

Why does the width jump to 100%

You're animating between a pixel width and a percent width so it can't smoothly animate (neither of your demos work very smoothly on my computer). 


I really don't understand what @midnightgamer is trying to do with the CSS of .text-div. Here's how I'd set it up:

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


Note that I also changed your start and end positions because your end position was before your start position which made the tween finish instantly.

  • Like 2
Link to comment
Share on other sites

1 hour ago, mikel said:

Hey Zach,








Thanks It is exactly what I was looking for.

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.