Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // send first ball from (0, 0) to (200, 0)
- animate(firstBall, 0, 200)();
- // send second ball from (0, 0) to (100, 0) but with the tempo like it was sent to (200, 0)
- animateWithTweak(secondBall, 0, 100, 200)();
- function animate(ball, start, intended) {
- return function () {
- ball.animate({cx: intended}, 2000, ">");
- }
- }
- function animateWithTweak(ball, start, real, intended) {
- var distanceRatio = (real - start) / (intended - start);
- var timeRatio = 1 - Math.pow(1 - distanceRatio, 1/3);
- Raphael.easing_formulas["custom"] = function(n) {
- var f = Raphael.easing_formulas[">"];
- return (1 / distanceRatio) * f(timeRatio * n);
- }
- return function () {
- ball.animate({cx: real}, 2000 * timeRatio, "custom");
- };
- }
Add Comment
Please, Sign In to add comment