Kem*_*ief 8 javascript animation raphael
大家好,我使用Raphael框架制作了这个动画.我希望明星(logoStar)无限旋转,但它只运行一次.有人可以帮忙吗?谢谢
window.onload = function () {
buildLogo();
}
var buildLogo = function () {
var logo = Raphael("title",800,236);
var logoStar = logo.path("M12.245 131.057L16.039 138.743L24.521 139.974L18.383 145.958L19.832 154.406L12.245 150.418L4.658 154.406L6.108 145.958L-0.03 139.974L8.452 138.743").attr({fill:"#fff",stroke:"none"});
var starSpin = function () {
logoStar.animate({rotation: "360"}, 5000, starSpin);
}
starSpin();
}
Run Code Online (Sandbox Code Playgroud)
Dmi*_*kiy 18
var starSpin = function () {
logoStar.attr({rotation: 0}).animate({rotation: 360}, 5000, starSpin);
}
Run Code Online (Sandbox Code Playgroud)
从360°到360°的动画看起来没有动画,因此您需要在之前将旋转重置为零.
自从第2版问世以来,拥有无限循环动画的真正方法是:
var spin = Raphael.animation({transform: "r360"}, 2500).repeat(Infinity);
myElement.animate(spin);
Run Code Online (Sandbox Code Playgroud)
Infinity是Javascript中的属性,因此不要将其作为字符串输入.
这是一个工作小提琴.