Jump to content
Search Community

smooth back and forth (reciprocating) motion question

kremzeek test
Moderator Tag

Recommended Posts

Originally I posted the question here: 

https://stackoverflow.com/questions/61199816/using-keyframe-animation-to-smoothly-change-margins-of-images-to-show-back-and-f

 

The gist of it is - I'm new to Greensock and want to see if the reciprocating motion seen in the codepen (css animation) can be 

improved using Greensock - ie) no jitters  - all smooth...?

 

Thx

See the Pen LYNzYOm by cw132 (@cw132) on CodePen

Link to comment
Share on other sites

Hey kremzeek and welcome to the GreenSock forums! You're going to love GSAP :) 

 

The issue is primarily with the property that you're animating - margin. It's not a performant thing to animate because it causes reflow, repaint, you name it :) You should stick to translations instead as much as possible. In GSAP you can just use the x property.

 

However, part of the issue is simply the distance that you're moving it (small) over the duration (fairly long). Elements can only be moved in 1 pixel increments so it will be jumpy to some degree even if you're using translations. 

 

I'm not sure what your end goal is (happy to help if you do) but here's a demo based on your demo:

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

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