आखिर में मेरा जवाब है: पृष्ठ में सबकुछ एनिमेट करने वाला केवल एक टाइमर है। अगर कोई कतार में कुछ है, एक टाइमर बनाई गई है सब कुछ चलता है कि और जैसे ही सब कुछ किया जाता है, टाइमर मार दिया जाता है:
एचटीएमएल उपयोग किया:
<div id="test1" class="tests" style="background-color:#FFF; border:1px solid #000; width:40px; height:40px; position:absolute; left:0px; top:0px;"></div>
<div id="test2" class="tests" style="background-color:#FFF; border:1px solid #000; width:40px; height:40px; position:absolute; left:0px; top:50px;"></div>
जावास्क्रिप्ट उपयोग किया:
var setIntervalDecorated = setInterval;
setInterval = function(func, delai) {
var id = setIntervalDecorated(func, delai);
console.log('setInterval: ' + id + ' (' + delai + 'ms)');
return id;
};
var clearIntervalDecorated = clearInterval;
clearInterval = function(id) {
console.log('clearInterval: ' + id);
clearIntervalDecorated(id);
};
टेस्ट मामला:
टेस्ट 1
$('#test1').animate({ left: '+=500' }, 5000, function() { console.log('test1: Animation complete'); });
setInterval: 5 (13ms)
test1: Animation complete
clearInterval: 5
टेस्ट 2
$('.tests').animate({ left: '+=500' }, 5000, function() { console.log('tests: Animation complete'); });
setInterval: 5 (13ms)
tests: Animation complete
tests: Animation complete
tests: Animation complete
clearInterval: 5
टेस्ट 3
$('#test1').animate({ left: '+=500' }, 5000, function() { console.log('test1: Animation complete'); });
$('#test2').animate({ left: '+=500' }, 5000, function() { console.log('test2: Animation complete'); });
setInterval: 5 (13ms)
test1: Animation complete
test2: Animation complete
clearInterval: 5
टेस्ट 4
$('#test1').animate({ left: '+=500' }, 5000, function() { console.log('test1: Animation complete'); });
setTimeout(function() { $('#test2').animate({ left: '+=500' }, 5000, function() { console.log('test2: Animation complete'); }); }, 1000);
setInterval: 5 (13ms)
test1: Animation complete
test2: Animation complete
clearInterval: 5
धन्यवाद
क्या आपने सोर्सकोड देखा है? – Marius
मेरे पास एक peek –
होगा, मैंने इसे देखा, कतार को नीचे जैसा देखा .. लेकिन "सेटटाइमआउट" या "सेट इटरवाल" भी नहीं देखा ... मैं कल और अधिक गहराई से खोदूँगा। –