moofx icon indicating copy to clipboard operation
moofx copied to clipboard

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

Open oskarkrawczyk opened this issue 13 years ago • 4 comments

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?

oskarkrawczyk avatar Oct 27 '12 17:10 oskarkrawczyk

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

arian avatar Oct 27 '12 18:10 arian

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').

arian avatar Oct 27 '12 18:10 arian

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

oskarkrawczyk avatar Oct 27 '12 19:10 oskarkrawczyk

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});

kamicane avatar Oct 31 '12 16:10 kamicane