Jump to content
GreenSock

usr1931990

Different widths - same duration

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

Is it possible?

I have many divs with text that have different width. I want them to move at the same animation speed. This is my code:

 

    startRolling: function($text, $wrap) {
      let duration = $wrap.width() / 40;
      TweenMax.to($wrap, duration, {
        x: -($text.width()),
        ease: Linear.easeNone,
        repeat: -1
      });
    }

 

So this doesn't work, and setting the duration manually to for instance .9 obviously doesn't work.

 

Thanks!

Link to comment
Share on other sites

@helleholmsen,

 

There are a few times in the past where I've shown how to deal with similar speeds over different distances. Maybe these can help,

 

See the Pen grLqYB by sgorneau (@sgorneau) on CodePen

 

See the Pen mWEddP by sgorneau (@sgorneau) on CodePen

 

I'll try to find others (I wasn't very good at categorizing them ? )

 

  • Like 5
Link to comment
Share on other sites

My two cent approach:

 

See the Pen ardXWP by PointC (@PointC) on CodePen

 

Happy tweening.

:)

 

  • Like 5
Link to comment
Share on other sites

xPercent: -100,
x: window.innerWidth

 

image.png.26e3dd5650e6f71f0d4bad750b14c463.png

  • Like 1
  • Haha 2
Link to comment
Share on other sites

51 minutes ago, PointC said:

My two cent approach:

 

 

Very elegant Craig... a thought on how to make it responsive.

 

See the Pen byEZqK by Visual-Q (@Visual-Q) on CodePen

  • Like 4
Link to comment
Share on other sites

Sweet work @Visual-Q ?

 

Looks like this thread is getting pretty clever. I think we have one of these happening.

 

RW1eCjL.jpg

  • Like 2
  • Haha 2
Link to comment
Share on other sites

An extension to the previous pen...

 

In typical fashion around here, one thing leads to another and gets completely off the original topic. Extending Craig's elegant 

x: window.innerWidth

I think I might have come up with a fairly decent option for making transform based animations responsive. It basically uses the parent element as a stage and modifier to animate relative to it.

 

See the Pen XwXQGV by Visual-Q (@Visual-Q) on CodePen

 

 

  • Like 3
Link to comment
Share on other sites

You guys are having way too much fun with this ;)

 

Love it. 

  • Like 1
Link to comment
Share on other sites

Look at you lot, making translating boxes on a screen fashionable.

  • Haha 2
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.
×