[英]jQuery: wait for slide to finish before executing code
I want to wait the sliding animation is done before executing the code, as shown below: 我想等待滑动动画完成后再执行代码,如下所示:
$('#blueimp-gallery').on('slide', function (event, index, slide) {
$(this).find('.modal-citation')
.text($('#links a').eq(index).data('citation'));
});
I've tried a few ways of doing this, but none of them worked. 我已经尝试了几种方法来执行此操作,但是没有一种有效。
$('#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);
});
What is the right way of doing this? 正确的做法是什么?
You should be able to set this in the plugin options : 您应该可以在插件选项中进行设置:
// 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
}
Taken from : https://github.com/blueimp/Gallery/blob/master/README.md#event-callbacks 摘自: https : //github.com/blueimp/Gallery/blob/master/README.md#event-callbacks
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.