• 移动端 touch 事件的originalEvent Chris


      对于移动端的触摸事件,我们通过touchstart、touchmove、touchend实现,PC端一般使用mousedown、mousemove、mouseup实现。

      我们获取事件坐标,原生js获取方式

    mousedown event.pageX
    mousemove event.pageX
    mouseup event.pageX
    touchstart event.touches[0].pageX  &  event.changedTouches[0].pageX  &  event.targetTouches[0].pageX
    touchmove event.touches[0].pageX  &  event.changedTouches[0].pageX  &  event.targetTouches[0].pageX
    touchend event.touches[0].pageX  &  event.changedTouches[0].pageX  &  event.targetTouches[0].pageX

      jQuery获取方式

    mousedown event.pageX
    mousemove event.pageX
    mouseup event.pageX
    touchstart event.originalEvent.touches[0].pageX  &  event.originalEvent.changedTouches[0].pageX  &  event.originalEvent.targetTouches[0].pageX
    touchmove event.originalEvent.touches[0].pageX  &  event.originalEvent.changedTouches[0].pageX  &  event.originalEvent.targetTouches[0].pageX
    touchend event.originalEvent.changedTouches[0].pageX  &  event.originalEvent.targetTouches[0].pageX

      其中关于touch触摸事件的触摸列表:

        touches :当前位于屏幕上的所有手指的一个列表。
        targetTouches :位于当前DOM元素上的手指的一个列表。
        changedTouches :涉及当前事件的手指的一个列表。

      对于jQuery中在移动端获取坐标使用的event.originalEvent,有以下:

      It's also important to note that the event object contains a property called originalEvent, which is the event object that the browser itself created. jQuery wraps this native event object with some useful methods and properties, but in some instances, you'll need to access the original event via event.originalEvent for instance. This is especially useful for touch events on mobile devices and tablets.

      event.originalEvent is usually just the native event (also described here).

      However, if the browser is compatible, and the event was a touch event then that API will be exposed through event.originalEvent.

      The short answer is that event.originalEvent is not always the same, it depends on which event type triggered the handler, and on the environment of the browser.

      关于event.originalEvent说明的地址链接:http://stackoverflow.com/questions/16674963/event-originalevent-jquery

      关于touch事件的补充内容地址链接:http://blog.csdn.net/clh604/article/details/9861411

    如需转载请注明出处。
  • 相关阅读:
    利用ApplicationListener和ContextRefreshedEvent加载自己的beanPool
    java对象转变为map
    Java通过poi创建Excel文件并分页追加数据
    Java通过poi读取excel中文件
    SpringMvc通过controller上传文件代码示例
    SpringCloud组件学习-图
    Java-线程间通信小结
    Java-关于Thread
    Java-对象及变量的并发访问小结
    java爬取免费HTTP代理 code-for-fun
  • 原文地址:https://www.cnblogs.com/dongcanliang/p/5749270.html
Copyright © 2020-2023  润新知