//增加第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();的理解