javascript - jQuery Animate transform infinite -
i need set infinite rotating doesn't work.
function animaterotate(angle) { var $elem = $('.icon-repeat'); $({deg: 0}).animate({deg: angle}, { duration: 5000, step: function(now) { $elem.css({ transform: 'rotate(' + + 'deg) infinite' }); } }); }
that code, , line transform: 'rotate(' + + 'deg) infinite' .. if remove infinite works 1 rotate, need rotate infinite.. have write in js, think...
try this, should set "repeat" value. animaterotate(degree, repeatcount).
in case set repeatcount "infinite".
function animaterotate(angle,repeat) { var duration= 1000; settimeout(function() { if(repeat && repeat == "infinite") { animaterotate(angle,repeat); } else if ( repeat && repeat > 1) { animaterotate(angle, repeat-1); } },duration) var $elem = $('.icon-repeat'); $({deg: 0}).animate({deg: angle}, { duration: duration, step: function(now) { $elem.css({ 'transform': 'rotate('+ +'deg)' }); } }); } animaterotate(45,"infinite");
Comments
Post a Comment