Giter Club home page Giter Club logo

pathanimator's Introduction

Path Animator

Moves a DOM element along an SVG path (or do whatever along a path...)

Basic use example:

var path             = "M150 0 L75 200 L225 200 Z";    // an SVG path
    pathAnimator,
    startFromPercent = 10,  // start from 10% of the path
    stopAtPercent    = 70;  // stop at 70% of the path (which will then call the onDone function callback)


// initiate a new pathAnimator object
pathAnimator = new PathAnimator( path, {
    duration : 4, // seconds that will take going through the whole path
    step     : step,
    easing   : function(t){ return t*(2-t) },
    onDone   : finish(this)
});

pathAnimator.start( startFromPercent, stopAtPercent  );

function step( point, angle ){
    // do something every "frame" with: point.x, point.y & angle
}

function finish(){
    // do something when animation is done
}

Settings

Name Type Default Info
duration Number undefined (in seconds) the duration of going through the path
step Function undefined a callback function which is called on every frame
onDone Function undefined (optional) a callback function which will be called at the end
reverse Boolean false go back or forward along the path
startPercent Number 0 Where to start on the path, between 0% to 100%
easing Function 1000/60 (optional) mathematical function for easing
fps Number undefined (optional) frames per second

pathanimator's People

Contributors

yaireo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pathanimator's Issues

Impossible to stop walker from step()

The script calls the step function and then "resets" the timer. This makes it impossible to stop the walker from the step() method since the timer will get immediatelly overwritten.

Switch the order of those calls and it works perfectly.

Firefox support

The pathAnimator library is showing weird issues on firefox. The demo page doesn't seem to be working at all (walker is not even visible on the screen, he is off walking far in the distance).

Any idea why?

is there a way to 'place' an item along a path without starting the animation?

For example, I have a bunch of cars on a track that need to idle at the grid until we tell them to start moving. Preferably I would say car1 at 99% of the path, car2 at 98%, etc. It seems like pathAnimator would have most of the info I need to accomplish this.

Currently they all sit at x0, y0 and I use SVG translate to move them. Could I get the x,y point of my path at 99%, 98% etc?

Safari support

There appear to be movement bugs when testing this in Safari. In some cases the walker object/s doesn't move at all or sticks at certain points.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.