Jump to content
Search Community

Zoom in effect

JoPed test
Moderator Tag

Go to solution Solved by GreenSock,

Recommended Posts

  • Solution

Hi @JoPed. I'm struggling to understand what you mean because your demo just uses scrub: true, so it goes "back to the default state" in exactly the reverse way as it came in. There's no "lack of smoothness" for me and I don't see any snapping either. Also...

  1. Don't use transform: "translate(0) scale(1)" - that's the worst for both performance and accuracy. Just use the built-in GSAP shortcuts like scale, x, y, rotation, etc. So in your case, {x: 0, y: 0, scale: 1}. Always set the initial values via GSAP too. In your case, gsap.set("#ninja", {x: -100, xPercent: 0, scale: 0.6});
  2. You definitely shouldn't be animating "transitionDuration" - using CSS transitions with GSAP is usually a very bad idea. Just use GSAP to do the animation. 

Are you trying to have it take longer to animate in/out? Maybe just alter the start/end positions? And you can use something like scrub: 1 to make the scrub take 1 second to "catch up": 

https://codesandbox.io/s/zoom-in-effect-forked-zxtbc9?file=/src/Test.js

 

I hope that helps.

Link to comment
Share on other sites

3 hours ago, GreenSock said:

Hi @JoPed. I'm struggling to understand what you mean because your demo just uses scrub: true, so it goes "back to the default state" in exactly the reverse way as it came in. There's no "lack of smoothness" for me and I don't see any snapping either. Also...

  1. Don't use transform: "translate(0) scale(1)" - that's the worst for both performance and accuracy. Just use the built-in GSAP shortcuts like scale, x, y, rotation, etc. So in your case, {x: 0, y: 0, scale: 1}. Always set the initial values via GSAP too. In your case, gsap.set("#ninja", {x: -100, xPercent: 0, scale: 0.6});
  2. You definitely shouldn't be animating "transitionDuration" - using CSS transitions with GSAP is usually a very bad idea. Just use GSAP to do the animation. 

Are you trying to have it take longer to animate in/out? Maybe just alter the start/end positions? And you can use something like scrub: 1 to make the scrub take 1 second to "catch up": 

https://codesandbox.io/s/zoom-in-effect-forked-zxtbc9?file=/src/Test.js

 

I hope that helps.

Thank you for the response.

 

Ah of course, that makes sense with the scrub. And I never knew about the CSS part. Thank you so much!

 

And to answer your question, I was trying to make the out animation not seem so jumpy (hope that makes sense?).

 

EDIT: After testing the edited codesandbox it looks much better. Again, thank you for your time!

Edited by JoPed
Edit after testing solution
  • 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...