Viewing 4 posts - 1 through 4 (of 4 total)
  • Javascript animation equation
  • bluebird
    Free Member

    I need to animate a DIV sliding left to right, but I want it to overshoot.

    I have a variable, for the sake of argument X, that increments between 0 and 1 to represent the percentage complete. This is then used to multiply a second variable that holds the total distance that needs to be moved to create the animation.

    I’d like to be able to pass X to a function that returns 0 when passed 0, 1 when passed 1, but at some point (around 0.85) over shoots 1. I hope that makes sense.

    Can any point me in the direction of a suitable equation.

    Thanks.

    whatnobeer
    Free Member

    something like

    function incX(x)
    {
    if(x == 1){
    return 1
    }
    if (x==0){
    return 0
    }
    return (1.29 * x)

    }

    That syntax is probably wrong but its been a while since I’ve done javascript.

    Bez
    Full Member

    Don’t reinvent the wheel. Use JQuery.

    bluebird
    Free Member

    I’ve worked it out now. Can’t use JQuery.

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Javascript animation equation’ is closed to new replies.