javascript - Famo.us Js - Animate Body (Particle) to Position -
i have circle (which i'll refer particle throughout question) modifier surface added pipes events generic sync (touch/click). sync events allow me change position of particle on start, update , end events can drag around within bounding box.
there's rule in application if distance between particle's position on sync's start , end events under threshold, particle needs animate start position.
for example: particle starts @ [0,0] on sync start, , moved [100,100]. distance between 2 points (about ~141.42) exceeds threshold of 50...
how can apply force/velocity/?? animate particle [0,0]?
note: know can modifiers pretty easily, i'm trying strictly use physics engine.
edit: figured out solution involves using transitionable , setting interval run updates particle's position, setting transitionable desired final position , clearing interval in transitionable's callback.
var retreattrans = new transitionable(myparticle.getposition()); // set temporary interval update position // change transitionable (below) var retreatinterval = setinterval(function () { myparticle.setposition(retreattrans.get()); }); // set transitionable our desired retreatposition retreattrans.set([0,0], {duration: 100}, function () { // clear our interval clearinterval(retreatinterval); });
if i'm understanding question correctly, want drag particle/circle/rectangle origin , on touchend have particle/circle/rectangle move origin.
one of ways accomplish withe physics engine through spring. if @ scrollview, internally uses spring "bounce" when reach edge. i'll see if can work quick implementation later demonstrate this.
Comments
Post a Comment