1. <legend id='1TSC1'><style id='1TSC1'><dir id='1TSC1'><q id='1TSC1'></q></dir></style></legend>
      • <bdo id='1TSC1'></bdo><ul id='1TSC1'></ul>

      <small id='1TSC1'></small><noframes id='1TSC1'>

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

        在 iOS 5 上 document.ontouchmove 和滚动

        时间:2023-09-06
          <legend id='5zUph'><style id='5zUph'><dir id='5zUph'><q id='5zUph'></q></dir></style></legend>

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

            • <tfoot id='5zUph'></tfoot>
                <tbody id='5zUph'></tbody>

                  <bdo id='5zUph'></bdo><ul id='5zUph'></ul>

                  <small id='5zUph'></small><noframes id='5zUph'>

                  本文介绍了在 iOS 5 上 document.ontouchmove 和滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  iOS 5 为 JavaScript/Web 应用程序带来了许多好东西.其中之一是改进的滚动.如果你添加

                  iOS 5 has brought a number of nice things to JavaScript/Web Apps. One of them is improved scrolling. If you add

                  -webkit-overflow-scroll:touch;
                  

                  对于 textarea 元素的样式,用一根手指就可以很好地滚动.

                  to the style of a textarea element, scrolling will work nicely with one finger.

                  但是有一个问题.为了防止整个屏幕滚动,建议web应用添加这行代码:

                  But there's a problem. To prevent the entire screen from scrolling, it is recommended that web apps add this line of code:

                  document.ontouchmove = function(e) {e.preventDefault()};
                  

                  但是,这会禁用新的滚动.

                  This, however, disables the new scrolling.

                  有没有人有一个很好的方法来允许在文本区域内进行新的滚动,但不允许整个表单滚动?

                  Does anyone have a nice way to allow the new scrolling within a textarea, but not allow the whole form to scroll?

                  推荐答案

                  更新根据 Alvaro 的评论,此解决方案可能不再适用于 iOS 11.3.

                  Update Per Alvaro's comment, this solution may no longer work as of iOS 11.3.

                  您应该能够通过选择是否调用 preventDefault 来允许滚动.例如,

                  You should be able to allow scrolling by selecting whether or not preventDefault is called. E.g.,

                  document.ontouchmove = function(e) {
                      var target = e.currentTarget;
                      while(target) {
                          if(checkIfElementShouldScroll(target))
                              return;
                          target = target.parentNode;
                      }
                  
                      e.preventDefault();
                  };
                  

                  或者,这可以通过阻止事件到达文档级别来实现.

                  Alternatively, this may work by preventing the event from reaching the document level.

                  elementYouWantToScroll.ontouchmove = function(e) {
                      e.stopPropagation();
                  };
                  

                  编辑对于以后阅读的任何人来说,备用答案确实有效并且更容易.

                  Edit For anyone reading later, the alternate answer does work and is way easier.

                  这篇关于在 iOS 5 上 document.ontouchmove 和滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:在 NGINX docker 容器中启动之前运行 bash 脚本 下一篇:导航返回/未触发事件时 iOS 5 Safari 中的页面缓存

                  相关文章

                  最新文章

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

                  1. <tfoot id='2o60Z'></tfoot>

                    <small id='2o60Z'></small><noframes id='2o60Z'>

                    1. <legend id='2o60Z'><style id='2o60Z'><dir id='2o60Z'><q id='2o60Z'></q></dir></style></legend>