Preferred Alternative to OnMouseOver for touch

前端 未结 5 1761
终归单人心
终归单人心 2020-11-28 10:16

Is there a preferred alternative or best practice for handling OnMouseOver javascript events on touch devices? All I can think is to convert all events to OnMouseClick. Un

5条回答
  •  抹茶落季
    2020-11-28 11:08

    The onmouseover/onmouseout javascript events would translate to the touchenter/touchleave touch events, the problem is these events are just starting to being implemented in browsers (they are part of a W3C draft), currently only firefox support it, so if you are using webkit you'll have to wait for it, or implement your onmouseover feature using touchmove event and looking at the coordinates and to see if they overlap with the coordinates of your html element.

提交回复
热议问题