Comments (15)
好的,我今天晚上弄个在线 demo,到时候发你看一下
from any-touch.
已修复, 还没写用例, 暂不发版
from any-touch.
兄弟你上面描述的第二段好像有打错字的地方, 所以我没太看懂你的需求, 你先说下你需要用到哪几个手势, 我帮你分析下怎么弄
from any-touch.
preventDefault实际他的值可以是函数, 函数的参数是当前元素的事件对象, 所以可以根据元素上的属性来决定是否"阻止浏览器默认行为"
不知道这点能否解决你的问题, 不行咱俩再研究
from any-touch.
我其实就一个固定高度的盒子里面有加载一些 item,就像上面图里面的 a301 a302 这样的,然后我要把选中的拖动(其实就是做个效果)。我就是在盒子上绑定的 pan 事件,拖动的时候有个半透明的 div 显示拖动效果这样,拖到右边的区域就把选中的 item 放到右边这样。
然后现在我是盒子作为 anytouch 的绑定元素,盒子我是设置的overflow: auto,但是在移动端无法滚动
from any-touch.
然后这些 item 我现在用的是 tap 来进行选中的,在不使用 preventDefault 的时候 click 在移动端是不生效,我也看过之前的 issue,现在换成 tap 能正常工作。但是如果用 preventDefault: false 的话 tap 好像就要按住大概 0.5s 才能生效。
from any-touch.
preventDefault实际他的值可以是函数, 函数的参数是当前元素的事件对象, 所以可以根据元素上的属性来决定是否"阻止浏览器默认行为"
不知道这点能否解决你的问题, 不行咱俩再研究
好的,我试试,谢谢你这么快回复我。
from any-touch.
客气啦. tap并没有延迟啊, 你是开启"双击"了吗? 你现在用的any-touch的版本是多少?
from any-touch.
我用的版本是 2.1.2,我是开了 preventDefault: false 在移动端需要长按(就是如果像click一样就点一下,就没效果),开了以后 click 就可以正常用,我试试看截图能不能看出来。
from any-touch.
确实是双击的问题,事件触发了两次
from any-touch.
不过我也没特别开启双击,这个需要手动关闭么
from any-touch.
确实是双击的问题,事件触发了两次
不应该啊, 我本地运行了2.1.2的源码, 并没有默认开启双击, 而且开启了preventDefault:false后tap也是瞬发啊.
运行这个可以看到的加载了哪些手势:
console.log(at.__pluginContexts);
from any-touch.
话说回逻辑吧, 我明白了你的需求. 但是既然想要拖拽, 那么就没办法不"阻止滚动", 因为浏览器也不知道你是要拖拽物体还是要滚动列表, 所以这里建议在UI上改一下, 比如:
给列表的内边距增大, 同时通过preventDefault函数来保证只有拖拽item的时候阻止默认, 这样其他地方的拖拽就会产生滚动.
from any-touch.
话说回逻辑吧, 我明白了你的需求. 但是既然想要拖拽, 那么就没办法不组织滚动, 因为浏览器也不知道你是要拖拽物体还是要滚动列表, 所以这里建议在UI上改一下, 比如: 给列表的内边距增大, 同时通过preventDefault函数来保证只有拖拽item的时候阻止默认, 这样其他地方的拖拽就会产生滚动.
我打印了好像是只加载了默认的六种手势,是不是我的 tap 绑定有什么问题,我就是在盒子内的 v-for 上面给每个元素绑定的 tap。我也是第一次做这种手势相关的,谢谢你的这个开源库还有建议,我后面去改一改。
from any-touch.
应该不是绑定的问题, 我demo里也是这么写的, 有机会你弄个的在线的demo, 我现在没复现出来.
我打印了好像是只加载了默认的六种手势,是不是我的 tap 绑定有什么问题,我就是在盒子内的 v-for 上面给每个元素绑定的 tap。我也是第一次做这种手势相关的,谢谢你的这个开源库还有建议,我后面去改一改。
from any-touch.
Related Issues (20)
- 【BUG】Vue3 中指令方式设置参数没效果 HOT 2
- 【BUG】Vue3 press 按压事件不触发 HOT 6
- 原生js如何使用
- swipe 很难触发 HOT 1
- vue3指令版的doubletap无效 HOT 1
- @any-touch/pan 怎么动态设置 pointLength 呢 HOT 2
- 父元素监听 panmove, pinch 事件,子元素中 mousedown 不再触发 HOT 2
- 希望能支持在捕获阶段处理事件 HOT 1
- 如何在uniapp 中使用? HOT 2
- canvas 下 绘制的文字如何使用? HOT 1
- 有关 changelog HOT 1
- press 事件是否有按压中以及结束的回调。 HOT 2
- souce map 警告处理下呗
- 不传入el,用catchEvent传入事件的方式,points无法初始化
- pan 事件支持触发的间隔吗?比如:移动指定的像素才触发一次 HOT 2
- 基于any-touch手势库封装的Vue(2 & 3)的指令 HOT 3
- 可以在canvas上使用吗? HOT 4
- 慢速拖动时 panend 有很大几率不触发 HOT 16
- [doc] Add the library compatibility information? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from any-touch.