【发布时间】:2017-04-11 13:26:56
【问题描述】:
我正在使用BlueImp Gallery (DEMO)。我需要在某些情况下锁定隐藏按钮,效果很好。但现在我还需要隐藏鼠标和触摸滑动。
说明:用户可以向左或向右滑动,这将改变当前的图片。
我还没有找到负责的事件。如何停用滑动事件并再次激活它?这可能吗?
【问题讨论】:
标签: javascript jquery blueimp
我正在使用BlueImp Gallery (DEMO)。我需要在某些情况下锁定隐藏按钮,效果很好。但现在我还需要隐藏鼠标和触摸滑动。
说明:用户可以向左或向右滑动,这将改变当前的图片。
我还没有找到负责的事件。如何停用滑动事件并再次激活它?这可能吗?
【问题讨论】:
标签: javascript jquery blueimp
他们无意发布此功能,但它就在那里。
var galleryContext
// initalize your gallery
blueimp.Gallery([{/* your images */}], {
// we need the context of the gallery
onopened: function () {
galleryContext = this
}
})
// now disable
galleryContext.destroyEventListeners()
// or enable
galleryContext.initEventListeners()
【讨论】:
你可以用on()点赞,
$(document).on('click touchmove',function(){
if(CERTAIN_SITUATIONS){ // only on certain situations
return false;// it will prevent to do anything in your document
}
});
如果你想禁用一个 div 或容器,然后像这样使用它,
$(document).on('click touchmove','CONTAINER_ID_OR_CLASS',function(){
....
你可以使用stopPropagation()来防止冒泡,
$(document).on('click touchmove',function(e){
if(CERTAIN_SITUATIONS){ // only on certain situations
e.stopPropagation();
return false;// it will prevent to do anything in your document
}
});
【讨论】:
bubbling 在这种情况下是什么意思?
这对我有用:(在 v3.2.0 上测试)
this.galleryInstance = blueimp(this.config.images, options);
this.galleryInstance.destroyEventListeners();
//this line makes sure no touch events are registered in the init function
//and preserving other events in tact
this.galleryInstance.support.touch = false;
this.galleryInstance.initEventListeners();
【讨论】: