• 移动端触摸事件


    原生  ontouchstart  ontouchmove  ontouchend

        obj.addEventListener('touchstart',start)

            obj.addEventListener('touchmove',move)

        obj.addEventListener('touchend',end

    <a>点击我</a>

    <div>abc</div>

    div{position:absolute;left:0;top:0;background:#ff0000;}

    移动端中是可以使用鼠标上的事件,但是鼠标上的事件比移动端的touch类事件延迟执行,约300ms

    移动端事件(点透),当用户触发某个类似点击事件的时候,上层元素消失或者隐藏,因为click有300ms,在300ms之后目标点就会“漂移”;如果目标点有click事件(焦点事件)那么就会触发

    解决方案:   obj.addEventListener('touchstart',function(ev){

          ev.preventDefault()  //阻止默认行为

                 })

      如果需要跳转可以通过  window.location.href="url";

      iTools苹果录屏大师(手机端调试)

    ios10下设置了meta依然会缩放

    obj.addEventListener('touchstart',function(ev){

      ev.stopPropagation();     //阻止焦点元素的冒泡

    });

    1、touches  当前位于屏幕上的所有手指的一个列表

    2、targetTouches   位于当前DOM元素上的手指一个列表

    3、changedTouches   涉及当前事件的手指一个列表

  • 相关阅读:
    continue与break
    while循环
    获取数组元素
    函数的声明和调用
    匿名函数与自调用函数
    Supervisor离线安装及使用
    C++串口通讯解决方案
    C#项目管理引用的dll文件
    MFC自定义CStatusBar文字的颜色
    简单实用的批处理脚本
  • 原文地址:https://www.cnblogs.com/zgfa-blogs/p/6154663.html
Copyright © 2020-2023  润新知