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

    //增加第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 },
  • 相关阅读:
    update语句中存在''语法书写方式
    CSS的代码风格
    CSS的语法规范
    CSS层叠样式表导读
    CSS简介
    HTML基本标签(下)
    HTML基本标签(上)
    HTML简介导读
    集合及其运用
    字典的镶嵌
  • 原文地址:https://www.cnblogs.com/zhuji/p/12758539.html
Copyright © 2011-2022 走看看