【发布时间】:2013-04-08 18:46:39
【问题描述】:
有没有人在 Raphael 中使用 .animateWith() 成功地保持快速动画同步?它的记录很差。该库的创建者有一个video demonstration,但我找不到代码。
我有一个 Javascript 节拍器,它由一条线(节拍器的臂)和一个梯形“重量”组成,该重量最终会上下移动以表示速度。我有一个工作小提琴here,有问题的行是:
var ticktock = Raphael.animation({
"50%": { transform:"R20 " + x + "," + y, easing: "sinoid", callback: function() { tick(this, repeats, done); }},
"100%": { transform:"R-20 " + x + "," + y, easing: "sinoid", callback: function() { tick(this, repeats, done); }}
}, interval).repeat(repeats / 2);
arm.animate(ticktock);
weight.animateWith(arm, ticktock, ticktock);
如果您检查小提琴并给它一个高节奏和大约 20 个滴答声,您应该会看到重量滞后于手臂。 (如果不是,请尝试几次——墨菲定律等。)我认为这正是 animateWith() 所阻止的。可能是我用错了。
如果您查看 .animateWith() 函数的 Raphael source,您会看到它同步了每个动画 FWIW 的 .start 参数。
【问题讨论】:
标签: javascript animation raphael