GithubHelp home page GithubHelp logo

移动端无法滚动 about any-touch HOT 15 CLOSED

any86 avatar any86 commented on May 6, 2024
移动端无法滚动

from any-touch.

Comments (15)

Clloz avatar Clloz commented on May 6, 2024 1

好的,我今天晚上弄个在线 demo,到时候发你看一下

from any-touch.

any86 avatar any86 commented on May 6, 2024 1

已修复, 还没写用例, 暂不发版

from any-touch.

any86 avatar any86 commented on May 6, 2024

兄弟你上面描述的第二段好像有打错字的地方, 所以我没太看懂你的需求, 你先说下你需要用到哪几个手势, 我帮你分析下怎么弄

from any-touch.

any86 avatar any86 commented on May 6, 2024

preventDefault实际他的值可以是函数, 函数的参数是当前元素的事件对象, 所以可以根据元素上的属性来决定是否"阻止浏览器默认行为"

不知道这点能否解决你的问题, 不行咱俩再研究

from any-touch.

Clloz avatar Clloz commented on May 6, 2024

我其实就一个固定高度的盒子里面有加载一些 item,就像上面图里面的 a301 a302 这样的,然后我要把选中的拖动(其实就是做个效果)。我就是在盒子上绑定的 pan 事件,拖动的时候有个半透明的 div 显示拖动效果这样,拖到右边的区域就把选中的 item 放到右边这样。
然后现在我是盒子作为 anytouch 的绑定元素,盒子我是设置的overflow: auto,但是在移动端无法滚动

from any-touch.

Clloz avatar Clloz commented on May 6, 2024

然后这些 item 我现在用的是 tap 来进行选中的,在不使用 preventDefault 的时候 click 在移动端是不生效,我也看过之前的 issue,现在换成 tap 能正常工作。但是如果用 preventDefault: false 的话 tap 好像就要按住大概 0.5s 才能生效。

from any-touch.

Clloz avatar Clloz commented on May 6, 2024

preventDefault实际他的值可以是函数, 函数的参数是当前元素的事件对象, 所以可以根据元素上的属性来决定是否"阻止浏览器默认行为"

不知道这点能否解决你的问题, 不行咱俩再研究

好的,我试试,谢谢你这么快回复我。

from any-touch.

any86 avatar any86 commented on May 6, 2024

客气啦. tap并没有延迟啊, 你是开启"双击"了吗? 你现在用的any-touch的版本是多少?

from any-touch.

Clloz avatar Clloz commented on May 6, 2024

我用的版本是 2.1.2,我是开了 preventDefault: false 在移动端需要长按(就是如果像click一样就点一下,就没效果),开了以后 click 就可以正常用,我试试看截图能不能看出来。

from any-touch.

Clloz avatar Clloz commented on May 6, 2024

确实是双击的问题,事件触发了两次

from any-touch.

Clloz avatar Clloz commented on May 6, 2024

不过我也没特别开启双击,这个需要手动关闭么

from any-touch.

any86 avatar any86 commented on May 6, 2024

确实是双击的问题,事件触发了两次

不应该啊, 我本地运行了2.1.2的源码, 并没有默认开启双击, 而且开启了preventDefault:false后tap也是瞬发啊.

运行这个可以看到的加载了哪些手势:

console.log(at.__pluginContexts);

from any-touch.

any86 avatar any86 commented on May 6, 2024

话说回逻辑吧, 我明白了你的需求. 但是既然想要拖拽, 那么就没办法不"阻止滚动", 因为浏览器也不知道你是要拖拽物体还是要滚动列表, 所以这里建议在UI上改一下, 比如:
给列表的内边距增大, 同时通过preventDefault函数来保证只有拖拽item的时候阻止默认, 这样其他地方的拖拽就会产生滚动.

from any-touch.

Clloz avatar Clloz commented on May 6, 2024

话说回逻辑吧, 我明白了你的需求. 但是既然想要拖拽, 那么就没办法不组织滚动, 因为浏览器也不知道你是要拖拽物体还是要滚动列表, 所以这里建议在UI上改一下, 比如: 给列表的内边距增大, 同时通过preventDefault函数来保证只有拖拽item的时候阻止默认, 这样其他地方的拖拽就会产生滚动.

我打印了好像是只加载了默认的六种手势,是不是我的 tap 绑定有什么问题,我就是在盒子内的 v-for 上面给每个元素绑定的 tap。我也是第一次做这种手势相关的,谢谢你的这个开源库还有建议,我后面去改一改。

from any-touch.

any86 avatar any86 commented on May 6, 2024

应该不是绑定的问题, 我demo里也是这么写的, 有机会你弄个的在线的demo, 我现在没复现出来.

我打印了好像是只加载了默认的六种手势,是不是我的 tap 绑定有什么问题,我就是在盒子内的 v-for 上面给每个元素绑定的 tap。我也是第一次做这种手势相关的,谢谢你的这个开源库还有建议,我后面去改一改。

from any-touch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.