• <small id='eEg45'></small><noframes id='eEg45'>

      <i id='eEg45'><tr id='eEg45'><dt id='eEg45'><q id='eEg45'><span id='eEg45'><b id='eEg45'><form id='eEg45'><ins id='eEg45'></ins><ul id='eEg45'></ul><sub id='eEg45'></sub></form><legend id='eEg45'></legend><bdo id='eEg45'><pre id='eEg45'><center id='eEg45'></center></pre></bdo></b><th id='eEg45'></th></span></q></dt></tr></i><div id='eEg45'><tfoot id='eEg45'></tfoot><dl id='eEg45'><fieldset id='eEg45'></fieldset></dl></div>
        <bdo id='eEg45'></bdo><ul id='eEg45'></ul>
      1. <tfoot id='eEg45'></tfoot>
      2. <legend id='eEg45'><style id='eEg45'><dir id='eEg45'><q id='eEg45'></q></dir></style></legend>

      3. 触摸移动卡住 忽略取消触摸移动的尝试

        时间:2023-09-05
          <tfoot id='JhDH9'></tfoot>
        1. <i id='JhDH9'><tr id='JhDH9'><dt id='JhDH9'><q id='JhDH9'><span id='JhDH9'><b id='JhDH9'><form id='JhDH9'><ins id='JhDH9'></ins><ul id='JhDH9'></ul><sub id='JhDH9'></sub></form><legend id='JhDH9'></legend><bdo id='JhDH9'><pre id='JhDH9'><center id='JhDH9'></center></pre></bdo></b><th id='JhDH9'></th></span></q></dt></tr></i><div id='JhDH9'><tfoot id='JhDH9'></tfoot><dl id='JhDH9'><fieldset id='JhDH9'></fieldset></dl></div>

            <tbody id='JhDH9'></tbody>
          • <small id='JhDH9'></small><noframes id='JhDH9'>

              <bdo id='JhDH9'></bdo><ul id='JhDH9'></ul>
              <legend id='JhDH9'><style id='JhDH9'><dir id='JhDH9'><q id='JhDH9'></q></dir></style></legend>
                • 本文介绍了触摸移动卡住 忽略取消触摸移动的尝试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我在触摸滑块上弄乱了触摸事件,并且不断收到以下错误:

                  I'm messing around with touch events on a touch slider and I keep getting the following error:

                  使用cancelable=false 忽略取消touchmove 事件的尝试,例如,因为滚动正在进行中并且不能被打断了.

                  Ignored attempt to cancel a touchmove event with cancelable=false, for example because scrolling is in progress and cannot be interrupted.

                  我不确定是什么导致了这个问题,我刚接触触摸事件,似乎无法解决这个问题.

                  I'm not sure what is causing this problem, I am new to working with touch events and can't seem to fix this problem.

                  这里是处理触摸事件的代码:

                  Here is the code handling the touch event:

                  Slider.prototype.isSwipe = function(threshold) {
                      return Math.abs(deltaX) > Math.max(threshold, Math.abs(deltaY));
                  }
                  
                  
                  Slider.prototype.touchStart = function(e) {
                  
                      if (this._isSliding) return false;
                  
                        touchMoving = true;
                        deltaX = deltaY = 0;
                  
                      if (e.originalEvent.touches.length === 1) {
                  
                          startX = e.originalEvent.touches[0].pageX;
                          startY = e.originalEvent.touches[0].pageY;
                  
                          this._$slider.on('touchmove touchcancel', this.touchMove.bind(this)).one('touchend', this.touchEnd.bind(this));
                  
                          isFlick = true;
                  
                          window.setTimeout(function() {
                              isFlick = false;
                          }, flickTimeout);
                      }
                  }
                  
                  
                  Slider.prototype.touchMove = function(e) {
                  
                      deltaX = startX - e.originalEvent.touches[0].pageX;
                      deltaY = startY - e.originalEvent.touches[0].pageY;
                  
                      if(this.isSwipe(swipeThreshold)) {
                          e.preventDefault();
                          e.stopPropagation();
                          swiping = true;
                      }
                      if(swiping) {
                          this.slide(deltaX / this._sliderWidth, true)
                      }
                  }
                  
                  
                  Slider.prototype.touchEnd = function(e) {
                  
                      var threshold = isFlick ? swipeThreshold : this._sliderWidth / 2;
                  
                      if (this.isSwipe(threshold)) {
                          deltaX < 0 ? this.prev() : this.next();
                      }
                      else {
                          this.slide(0, !deltaX);
                      }
                  
                      swiping = false;
                  
                      this._$slider.off('touchmove', this.touchMove).one(transitionend, $.proxy(function() {
                          this.slide(0, true);
                          touchMoving = false;
                      }, this));
                  }
                  

                  您可以在在这支笔上找到实际的滑块.

                  You can find the actual slider here at this pen.

                  如果你刷得足够快,它会抛出错误,有时会卡在刷卡的中间.仍然无法理解为什么它不起作用.任何帮助/见解将不胜感激.不知道我做错了什么.

                  If you swipe through fast enough it will throw the error and sometimes get stuck in the middle of a swipe. Still can't wrap my head around why it is not working. Any help/insight would be greatly appreciated. Not sure what I am doing wrong.

                  推荐答案

                  事件必须是cancelable.添加 if 语句可解决此问题.

                  The event must be cancelable. Adding an if statement solves this issue.

                  if (e.cancelable) {
                     e.preventDefault();
                  }
                  

                  在你的代码中你应该把它放在这里:

                  In your code you should put it here:

                  if (this.isSwipe(swipeThreshold) && e.cancelable) {
                     e.preventDefault();
                     e.stopPropagation();
                     swiping = true;
                  }
                  

                  这篇关于触摸移动卡住 忽略取消触摸移动的尝试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:如果提交以编程方式启动,则提交事件不会触发 下一篇:Javascript 点击事件处理程序 - 我如何获得对点击项

                  相关文章

                  最新文章

                • <i id='lWfEv'><tr id='lWfEv'><dt id='lWfEv'><q id='lWfEv'><span id='lWfEv'><b id='lWfEv'><form id='lWfEv'><ins id='lWfEv'></ins><ul id='lWfEv'></ul><sub id='lWfEv'></sub></form><legend id='lWfEv'></legend><bdo id='lWfEv'><pre id='lWfEv'><center id='lWfEv'></center></pre></bdo></b><th id='lWfEv'></th></span></q></dt></tr></i><div id='lWfEv'><tfoot id='lWfEv'></tfoot><dl id='lWfEv'><fieldset id='lWfEv'></fieldset></dl></div>
                  <legend id='lWfEv'><style id='lWfEv'><dir id='lWfEv'><q id='lWfEv'></q></dir></style></legend>
                    <bdo id='lWfEv'></bdo><ul id='lWfEv'></ul>

                  1. <small id='lWfEv'></small><noframes id='lWfEv'>

                  2. <tfoot id='lWfEv'></tfoot>