kamicane / moofx

css3-enabled javascript animation library
MIT License
80 stars 15 forks source link

moofx().bezier([x,y], [x,y]) maybe? #14

Open oskarkrawczyk opened 12 years ago

oskarkrawczyk commented 12 years ago

More of a suggestion than an issue.

You think it's possible to utilize moofx in some way so it can be use to animate on a bezier curve?

arian commented 12 years ago

You can already do some things like: http://jsfiddle.net/GMXuF/14/

arian commented 12 years ago

Also what is your main goal, I mean, you can have bezier curves with n points, and you could write a solver for that (as described on http://en.wikipedia.org/wiki/B%C3%A9zier_curve for example). But then you must realize you can't easily translate that to the CSS3 timing function trick I used in the above jsfiddle, and you'll have to use the fx class (the JS-animate-anything 'fallback').

oskarkrawczyk commented 12 years ago

Didn't actually thought about using a custom equation, thanks for pointing it out Arian!

Generally the perfect scenario would be to set up a few x/y points in relation to the original position of the element, a bezier would automatically specify the animation path between each point. Now my math skills suck, so I was kind of hoping having a bezier method would be something that'd be interesting to more people than just me.

Edit: not that familiar with the terminology, so just googled a bit and what I describe above is a cubic/poly

kamicane commented 12 years ago

You can use the base fx class for any non-dom related animations, or to have a completely custom animation. Just require("moofx/lib/fx") or pass a function to moofx() rather than an element (i call this a renderer). This way you will get the base animation framework which is completely disconnected from css stuff. You can still use cubic beziers, or custom functions for equations.

An example would be:

moofx(function(now){someElement.style.left = now + 'px'}).start(0, 100, {equation: Penner.Equations.BounceBackWhatevs});