jQuery:在执行代码之前等待幻灯片完成

时间:2014-04-10 16:27:26

标签: javascript jquery

我想等待滑动动画在执行代码之前完成,如下所示:

$('#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);
});

这样做的正确方法是什么?

1 个答案:

答案 0 :(得分:0)

您应该可以在插件选项中设置它:

// 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

相关问题