为什么我的Raphael JS动画不会循环? [英] Why won't my Raphael JS animation loop?

查看:103
本文介绍了为什么我的Raphael JS动画不会循环?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好
我使用Raphael框架制作了这个动画。我希望明星(logoStar)无限旋转,但它只运行一次。有人可以帮忙吗?谢谢

Hi there I've made this animation using the Raphael framework. I want the star (logoStar) to spin indefinitely but it only runs once. Can anyone help? Thanks

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


推荐答案

var starSpin = function () {
    logoStar.attr({rotation: 0}).animate({rotation: 360}, 5000, starSpin);
}

从360°到360°的动画看起来没有动画,所以你需要之前将旋转重置为零。

Animation from 360° to 360° looks like there no animation, so you need to reset rotation to zero before.

这篇关于为什么我的Raphael JS动画不会循环?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆