2014-03-25 94 views
0

我做時鐘動畫效果很好,但我使用setinterval來調用函數。該動畫的同時開始[停止一段時間,在12]幾乎沒有延遲動畫不適當啓動

var timemin=0; 
var timehr=0; 
var timesec=0; 
var a=0; 
function clockRotate(){ 
timemin=timemin+6; 
timehr=timehr+0.5; 
timesec=timesec+360; 
$("#cimg3").animate({rotate:timemin},2500); 
$("#cimg4").animate({rotate:timesec},2500); 
$("#cimg2").animate({rotate:timehr},2500); 
} 

setInterval(function(){ 
clockRotate(); 
a=1; 
},0*2500); 

See The Action Here

如何刪除這種延遲。謝謝

回答

4

您應該使用"linear"。默認情況下它是「擺動」,這使得動畫在開始和結束時變得更慢。 Animate Documentation

var timemin=0; 
var timehr=0; 
var timesec=0; 
var a=0; 
function clockRotate(){ 
    timemin=timemin+6; 
    timehr=timehr+0.5; 
    timesec=timesec+360; 
    $("#cimg3").animate({rotate:timemin},2500,"linear"); 
    $("#cimg4").animate({rotate:timesec},2500,"linear"); 
    $("#cimg2").animate({rotate:timehr},2500,"linear"); 
} 

setInterval(function(){ 
    clockRotate(); 
    a=1; 
}, 0*2500); 

Fiddle

+1

感謝尼爾·沙阿:) – Arunkumar

0

而是缺乏寬鬆的屬性:

採取在這個fiddle

$("#cimg3").animate({ 
    rotate: timemin 
}, { 
    easing: "linear" 
}, 2500);