clearQueue metodu
clearQueue metodu bizə işe dushmemish
butun funksiyaları novbeden silmeye imkan verir.
Sintaksis
Biz funksiya novbesini belece temizleye bilerik. Isteye bagli parametr kimi
novbenin adını setir sheklinde vermek olar
(standart olaraq fx - standart
effektler novbesi). Heç bir parametr vermeseniz,
fx novbesinden qalan butun funksiyalar
silinecek:
.clearQueue([novbenin adı]);
Bu metod stop
metoduna oxshardır. Lakin,
sonuncu yalnız animasiya ile işleye biler,
clearQueue metodu ise istənilən jQuery
novbesi ile işlemeye imkan verir, hansı ki,
queue metodu
terefinden elave edilmishdir.
Numune
Gelin #start düymesine klikleyende,
animasiyanı işe salaq.
#stop düymesine klikleyende animasiyanı
dayandıracag ve novbeni clearQueue metodu
vasitesile temizleyeceyik.
#start düymesine tekrar klikleyende
animasiya yeniden bashlayacaq:
<button id="start">start</button>
<button id="stop">stop</button>
<div></div>
div {
position: absolute;
margin: 3px;
width: 50px;
height: 50px;
left: 0px;
top: 30px;
background: red;
display: none;
}
div.newcolor {
background: green;
}
$('#start').click(function() {
let myDiv = $('div');
myDiv.show('slow');
myDiv.animate({
left: '+=200'
}, 5000);
myDiv.queue(function() {
let that = $(this);
that.addClass('newcolor');
that.dequeue();
});
myDiv.animate({
left: '-=200'
}, 1500);
myDiv.queue(function() {
let that = $(this);
that.removeClass('newcolor');
that.dequeue();
});
myDiv.slideUp();
});
$('#stop').click(function() {
let myDiv = $('div');
myDiv.clearQueue();
myDiv.stop();
});