Jump to content
Search Community

Sliding text - on resize

ex-homedepot-cashier test
Moderator Tag

Recommended Posts

Hello,

 

I'm trying to have the text slide from side to side filling up the width of the screen. On initial load it seems to work just fine.

I am having trouble on resize. The animation seems to slow down a lot or pause completely.

 

I've tried to use the .clear and .remove methods with no luck.

 

Currently I have a window listener that runs the function again on resize.

See the Pen bGdVQeP by homedepot (@homedepot) on CodePen

Link to comment
Share on other sites

You're going to an absolute value each time, so each time a new tween is started its initial value gets closer to the end value (because you never clear it). You can use a fromTo with 0 in the from to reset it.

 

Also you're stacking up a bunch of setTimeouts on resize, you should clear out the old ones:

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

 

You don't need the ,0 in the tween either - that parameter is just for positioning in a timeline.

 

Hope that helps!

  • Thanks 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.
×
×
  • Create New...