![](/img/trans.png)
[英]Javascript will not wait for JQuery animation to finish before executing next command
[英]jQuery: wait for slide to finish before executing code
我想等待滑動動畫完成后再執行代碼,如下所示:
$('#blueimp-gallery').on('slide', function (event, index, slide) {
$(this).find('.modal-citation')
.text($('#links a').eq(index).data('citation'));
});
我已經嘗試了幾種方法來執行此操作,但是沒有一種有效。
$('#blueimp-gallery').on('slide', function (event, index, slide) {
$(this).find('.modal-citation')
.text($('#links a').eq(index).data('citation')).delay(3000); // didn't work
});
$('#blueimp-gallery').on('slide', function (event, index, slide) {
setTimeout(function () {
$(this).find('.modal-citation')
.text($('#links a').eq(index).data('citation')); // didn't work
}, 1000);
});
正確的做法是什么?
您應該可以在插件選項中進行設置:
// Callback function executed after the slide change transition.
// Is called with the gallery instance as "this" object and the
// current index and slide as arguments:
onslideend: function() {
// Do something
}
摘自: https : //github.com/blueimp/Gallery/blob/master/README.md#event-callbacks
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.