Jump to content
Search Community

Triggering Scale at specific point on path

mtbroomell test
Moderator Tag

Go to solution Solved by GreenSock,

Recommended Posts

Hello all,

 

Here is a codepen for my demo - 

Those red squares represent lottie animations which actually, for once, aren't the problem. They travel around a path using motionPath that is essentially a rounded trapezoid. I am trying to create an illusion of depth: when the box gets to the far right on the bottom row and starts moving up, I want it to begin scaling down to 75% and reach that size when it begins travelling left at the top.

My other efforts to this were extremely non-performant, involving checking absolute path locations inside of onUpdate which just battered the main thread. 

How would you all do this? Thanks so much!

See the Pen mdavYPm by Mark-Broomell (@Mark-Broomell) on CodePen

Link to comment
Share on other sites

  • Solution

Yeah, I definitely wouldn't be doing a ton of calculations inside an onUpdate and swapping classes or something. I'd probably just figure out the spots at which the scale should change (like keyframes) along the progress of the path and then create a separate scale animation for that: 

 

const scaleValues = [
  {progress: 0, scale: 0.5},
  {progress: 0.05, scale: 0.4},
  {progress: 0.27, scale: 0.4},
  {progress: 0.48, scale: 1},
  {progress: 0.85, scale: 1},
  {progress: 1, scale: 0.5}
];

 

And you probably don't need them all in a timeline. Think of it like each one is an infinitely repeating tween that's going along the same path, but you start them at different progress values: 

 

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

 

I hope that helps. 

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