Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom path animation using JQuery

I've created this android app that sends onTouchEvents points to a web server, and I have a page which gets the motion points JSON data via Ajax like so:

{"data":[
{"x":224.28035,"y":235.4906},
{"x":263.32916,"y":219.45718},
{"x":293.3667,"y":215.44885},.....]}

Now I want to use this data and animate a div on the screen with smooth path animation, similar to flash path animation, is there a plugin that solves this issue?

PS: http://weepy.github.com/jquery.path/ does not seem to have a custom path animation, or I may be missing something.

Thanks :)

like image 521
Shlomi Schwartz Avatar asked Feb 08 '12 14:02

Shlomi Schwartz


2 Answers

Hopefully this is the one you're searching for: jQuery plugin crSpline

You can see its demo in here.

like image 149
o q Avatar answered Nov 17 '22 00:11

o q


pathAnimator

Ultra-lightweight, high performance with a nice range of settings.

Example:

var path         = "M150 0 L75 200 L225 200 Z"; // an SVG path
    pathAnimator = new PathAnimator( path ),   // initiate a new pathAnimator object
    speed        = 6, // seconds that will take going through the whole path
    reverse      = false,  // go back or forward along the path
    startOffset  = 0,   // between 0% to 100%
    easing = function(t){ t*(2-t) };  // optional easing function


pathAnimator.start(speed, step, reverse, startOffset, finish, easing);

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

function finish(){
    // do something when animation is done
}
like image 4
vsync Avatar answered Nov 16 '22 23:11

vsync