繁体   English   中英

jQuery:等待幻灯片完成,然后再执行代码

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM