【问题标题】:BlueImp Gallery - How to deactivate swipe eventBlueImp Gallery - 如何停用滑动事件
【发布时间】:2017-04-11 13:26:56
【问题描述】:

我正在使用BlueImp Gallery (DEMO)。我需要在某些情况下锁定隐藏按钮,效果很好。但现在我还需要隐藏鼠标和触摸滑动。

说明:用户可以向左或向右滑动,这将改变当前的图片。

我还没有找到负责的事件。如何停用滑动事件并再次激活它?这可能吗?

【问题讨论】:

    标签: javascript jquery blueimp


    【解决方案1】:

    他们无意发布此功能,但它就在那里。

    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()
    

    【讨论】:

      【解决方案2】:

      你可以用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
         }
      });
      

      【讨论】:

      • 我想我必须创建一个解决方法来防止滑动。我将在画廊上放置一个透明的 div 来捕捉所有的鼠标点击、滑动等......
      • bubbling 在这种情况下是什么意思?
      【解决方案3】:

      这对我有用:(在 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();
      

      【讨论】:

        猜你喜欢
        • 2015-05-04
        • 2015-09-12
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-04-03
        • 1970-01-01
        相关资源
        最近更新 更多