JS:鼠标输入的触摸等效项 [英] JS: Touch equivalent for mouseenter

查看:26
本文介绍了JS:鼠标输入的触摸等效项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有与鼠标输入等效的触摸功能.

is there a touch equivalent of the mouseenter.

我想检测用户是否在我的 DIV 上滑动.

I would like to detect if user slide on my DIV.

我更喜欢直接依赖于目标元素而不是具有重新计数位置等的父元素的解决方案.

I prefer a solution depending directly on the target element not on a parent element with recounting positions etc.

网站:http://dizzyn.github.io/piano-game/- 使用鼠标正常工作(鼠标向下滑动;不适用于触摸滑动)

The site: http://dizzyn.github.io/piano-game/ - works fine with mouse (mouse down and slide; not working with touch slide)

谢谢

推荐答案

调查这些事件:

touchstart 当用户接触到触摸表面并在事件绑定到的元素内创建一个触摸点时触发.

touchstart Triggers when the user makes contact with the touch surface and creates a touch point inside the element the event is bound to.

touchmove 当用户在触摸表面上移动触摸点时触发.

touchmove Triggers when the user moves the touch point across the touch surface.

touchend 当用户从表面上移除一个触摸点时触发.无论触摸点是在绑定到元素内部还是外部移除,例如用户的手指首先滑出元素甚至离开屏幕边缘,它都会触发.

touchend Triggers when the user removes a touch point from the surface. It fires regardless of whether the touch point is removed while inside the bound-to element, or outside, such as if the user's finger slides out of the element first or even off the edge of the screen.

touchenter 当触摸点进入绑定元素时触发.此事件不会冒泡.

touchenter Triggers when the touch point enters the bound-to element. This event does not bubble.

touchleave 当触摸点离开绑定元素时触发.此事件不会冒泡.

touchleave Triggers when the touch point leaves the bound-to element. This event does not bubble.

touchcancel 当触摸点不再在触摸表面上注册时触发.例如,如果用户将触摸点移到浏览器 UI 之外或移到插件中,或者弹出警报模式,就会发生这种情况.

touchcancel Triggers when the touch point no longer registers on the touch surface. This can occur if the user has moved the touch point outside the browser UI or into a plugin, for example, or if an alert modal pops up.

特别是 touchenter 和 touchleave.

Specifically touchenter and touchleave.

http://www.javascriptkit.com/javatutors/touchevents.shtml

这篇关于JS:鼠标输入的触摸等效项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆