首页 > 移动平台 > 详细

Poptip插件拖动造成IOS下与同页面下mescroll.js也被拖动的解决,即对e.preventDefault();的理解

时间:2020-04-23 09:44:42      阅读:82      评论:0      收藏:0      [点我收藏+]

//增加第3行到第5行代码

 1 down() {
 2   this.flags = true;
 3   document.body.addEventListener(‘touchmove‘, function (e) {
 4     e.preventDefault();
 5   }, {passive: false});
 6   var touch;
 7   if (event.touches) {
 8     touch = event.touches[0];
 9   } else {
10     touch = event;
11   }
12   this.position.x = touch.clientX;
13   this.position.y = touch.clientY;
14   this.dx = moveDiv.offsetLeft;
15   this.dy = moveDiv.offsetTop;
16 },

//向下拖动Poptip后需要还原浏览器的"拖动事件"监听,参考第5行-7行代码

1 // 鼠标释放时候的函数
2 end() {
3   window.localStorage.setItem(‘position‘, JSON.stringify({x: this.xPum, y: this.yPum}));
4   this.flags = false;
5   document.body.addEventListener(‘touchmove‘, function (e) {
6     window.event.returnValue = true;
7   });
8 },

 

Poptip插件拖动造成IOS下与同页面下mescroll.js也被拖动的解决,即对e.preventDefault();的理解

原文:https://www.cnblogs.com/zhuji/p/12758539.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!