我有以下功能,我想继续为IE9的CSS动画制作回退动画。
问题是它旋转一次然后递归now
总是等于360.它再也不会从0开始。
谢谢:)
var App = {
init: function() {
console.log(Modernizr.cssanimations);
this.rotateSpinners();
},
rotateSpinners: function() {
$('.speed2').each(function() {
App.rotate($(this));
});
},
rotate: function(element) {
//console.log('---');
//console.log(element);
$(element).stop(true, true).animate(
{
rotation: 360
},
{
duration: 3600,
step: function(now) {
$(this).css({"transform": "rotate("+now+"deg)"});
//counts up to 360, second run always returns 360 without counting
console.log(now);
},
done: function() {
// tried to reset here
//$(this).css({"transform": "rotate(0deg)"});
App.rotate($(this));
}
}
);
}
};
App.init();
答案 0 :(得分:0)
尝试
var App = {
init: function() {
// console.log(Modernizr.cssanimations);
this.rotateSpinners();
},
rotateSpinners: function() {
$(".speed2").each(function() {
App.rotate(this);
});
},
rotate: function(element) {
// set, reset `element.style.rotation` at `0`
element.style.rotation = 0;
$(element).stop(true, true).animate(
{
rotation: 360
},
{
// set `easing` at `linear`
easing:"linear",
duration: 3600,
step: function(now) {
$(this).css("transform", "rotate(" + now + "deg)");
console.log(now);
},
done: function() {
App.rotate(this);
}
}
);
}
};
App.init();
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<div class="speed2">abc</div>