【发布时间】:2014-12-03 12:42:24
【问题描述】:
我正在尝试为 Nivo 灯箱中显示的项目实现 CSS 动画过渡。 我已经插入并运行了新函数,但以下 2 个函数在它完成之前运行。
$('.nivo-lightbox-prev').off('click').on('click', function(e){
e.preventDefault();
var index = galleryItems.index(currentLink);
currentLink = galleryItems.eq(index - 1);
if(!$(currentLink).length) currentLink = galleryItems.last();
$this.options.beforePrev.call(this, [ currentLink ]); # <---- new function I added
$this.processContent(content, currentLink); # <---- existing function 1
$this.options.onPrev.call(this, [ currentLink ]); # <---- existing function 2
});
我知道的唯一方法是将它们放入回调中,但 .call() 不接受回调。
我试过了:
function beforePrev(callback){
$this.options.beforePrev.call(this, [ currentLink ]);
callback();
}
function onPrev(){
$this.processContent(content, currentLink);
$this.options.onPrev.call(this, [ currentLink ]);
}
beforePrev(onPrev);
但它的行为是一样的。
如果相关,beforePrev 的代码是:
beforePrev: function() {
el = $('.nivo-lightbox-content');
el.addClass('animated fadeOutLeft');
el.one('webkitAnimationEnd oanimationend msAnimationEnd animationend', function (e) {
el.removeClass('fadeOutLeft');
});
},
谁能指出我正确的方向?
更新/编辑以提高清晰度: 这是完整的原始 Nivo 代码:link
根据我的阅读,$this 只是一个引用 init 函数的标准变量,而不是 DOM 对象。我认为这是这似乎很难做到的原因之一。
【问题讨论】:
标签: javascript jquery lightbox nivo-slider