Jump to content
Search Community

The locomotive

mikel test
Moderator Tag

Recommended Posts

Hey Zach,


Thanks to your code, I have clearly progressed in understanding.
Just for fun and learning I have a question:
How does the 'yValue' value come about? Can it be calculated? It doesn't turn around precisely.

 

 

I use gsap 2.0 for this case because I like the 'old' smooth start / stop function and cannot do this with 3.0.

 

The locomotive is already under construction. But here I have to specify the alignment of the parts.

 

See the Pen bGNjjyZ by mikeK (@mikeK) on CodePen

 

Kind regards

Mikel

See the Pen WNbaeJR by mikeK (@mikeK) on CodePen

Link to comment
Share on other sites

5 hours ago, mikel said:

How does the 'yValue' value come about?

I used trial and error. 

 

5 hours ago, mikel said:

Can it be calculated? It doesn't turn around precisely.

Probably. I didn't give it too much thought. The radius / 2 + strokeWidth is close (9.3). Not sure if that's mathematically correct. 

 

5 hours ago, mikel said:

I like the 'old' smooth start / stop function and cannot do this with 3.0.

What do you mean you cannot do it with GSAP 3?

Link to comment
Share on other sites

7 hours ago, mikel said:

But the drag part does not run as expected, as in gasp 2.0 - see above.

That's actually more of a "bug" in GSAP 2, and the fix is easy for GSAP 3. Let me explain... 

 

You're setting your rotation INSIDE of an onUpdate of a tween, but when you seek(), the default "suppressEvents" parameter is false, so it never calls the onUpdate! That's why your rotation isn't getting set. Easy fix: either set suppressEvents to false, like master.seek(this.x/40, false) or just use master.time(this.x/40) because the default suppressEvents for time() is false

 

Why was it working in v2? Because even when you set timeScale(0), it never actually let the timeScale be 0 (to avoid math issues with dividing by 0) - it made it a super small number. Since you didn't pause it, that means that technically the master tween kept running! So onUpdate was being called on every tick! Drop a console.log() in there and you'll see. Thus your rotation was getting set all the time. See why I'd consider that more of a "bug" with v2? Maybe not necessarily a "bug", but a little weird at least. :)

 

Does that clear things up? 

  • Like 2
Link to comment
Share on other sites

  • 1 month later...
On 1/22/2020 at 1:28 PM, mikel said:

Maybe I should do a course at @OSUblake.

 

Yes, you should! I'm accepting new applicants.

 

Lesson 1:

Use a sine.inOut ease to convert circular motion to linear motion.

 

Lesson 2:

Check out the new .convertCoordinates() function in the MotionPathPlugin.

 

See the Pen f5931e9308bc4380532a804fc8163589 by osublake (@osublake) on CodePen

 

 

  • Like 4
Link to comment
Share on other sites

On 2/29/2020 at 3:22 AM, OSUblake said:
On 1/22/2020 at 1:28 PM, mikel said:

Maybe I should do a course at @OSUblake.

Yes, you should! I'm accepting new applicants.

 

I hear ya @mikel, I've been doing the free course for years, invaluable.

 

If I had a dollar for every categorized topic folder on my computer that ended in: " -- OSUBlake", I could maybe afford the paid course by now. I have nightmares that there remains some post on the forum brimming with knowledge dust that I have missed - True story. 😄

 

That applies to so many users (a few mentioned here). People should really not hesitate to take advantage of the "search" feature, can't express that enough.

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