即使拖动旋转木马也启用点击互动(Materialise Carousel)

时间:2018-06-06 17:52:29

标签: angularjs carousel materialize

我在我的cordova应用程序页面上使用MaterialiseCSS(v0.100.2)轮播组件,并在研究默认情况下旋转木马禁用单击是否被拖动时发现,我查看了carousel.js文件并找到了以下代码:


    function click(e) {
    // Disable clicks if carousel was dragged.
      if (dragged) {
        e.preventDefault();
        e.stopPropagation();
        return false;
      } else if (!options.fullWidth) {
        var clickedIndex = $(e.target).closest('.carousel-item').index();
        var diff = wrap(center) - clickedIndex;
      // Disable clicks if carousel was shifted by click
        if (diff !== 0) {
          e.preventDefault();
          e.stopPropagation();
        }
        cycleTo(clickedIndex);
      }
    }

我尝试对这些内容发表评论:e.preventDefault();e.stopPropagation(),同时也将return false更改为return true但它无法正常工作 - 大概是这样的事实实际上并不知道那些线是做什么的。

这是我的.TS的一部分:


    $(document).ready(() => {
      $('.carousel').carousel({
      //Everytime the carousel is swiped (changed center item)
      onCycleTo: (ele) => {
        this._indexCarousel = $(ele).index();
        this.MainDivImage = this.Images[this.IndexCarousel];
      },
    });
    // I tried to map the items' click event but caused the bug.
    // Without this part the carousel works swiping but doesnt work clicking
    // $(".carousel-item").click( e => {
    //   literally anything I put here caused the carousel to bug
    // });
    });

TL; DR:我需要让旋转木马组件同时使用点击和拖动事件,到目前为止,我只能让它以一种形式或另一种形式工作......

0 个答案:

没有答案