Search code examples
javascriptgsapvelocity.js

Does VelocityJS has some "from" method like TweenMax?


In TweenMax i can do this:

TweenMax.from(block,3,{x:500,y:500});

To animate , in this case, to the original position (i hope i am being clear enough, but im sure that anybody that uses TweenMax knows what 'from' does at difference with the 'to').

How can achieve this same using VelocityJS?

Sorry if my question is maybe to naive, but i can't find how to do it.

Thanks in advance.


Solution

  • There isn't an actual corresponding method in Velocity that does that, so the best way to achieve this effect would be to set an element to its initial state in your CSS, and then animate it to its final state, along with force-feeding for best performance. Example:

    In your CSS:

    #block { transform: translateX(100%); }
    

    And in JS:

    Velocity(document.getElementById('block'), { translateX: [0, '100%'] });