mirror of
https://github.com/zhigang1992/react-native-web.git
synced 2026-05-08 02:39:21 +08:00
[change] ResponderEvent support for multi-input devices
Certain devices support both mouse and touch inputs. The Responder plugin needs to support this. Previously it would specific touch-only dependencies if touch support was detected. The recommended way to prevent browsers firing mouse events after touch events is to call `preventDefault` on the touch event. This may be problematic if/when `View` and `Touchable` support URLs/hrefs. Fix #169
This commit is contained in:
@@ -33,7 +33,7 @@ function normalizeTouchEvent(nativeEvent) {
|
||||
|
||||
const event = {
|
||||
changedTouches,
|
||||
domEvent: nativeEvent,
|
||||
originalEvent: nativeEvent,
|
||||
pageX: nativeEvent.pageX,
|
||||
pageY: nativeEvent.pageY,
|
||||
target: nativeEvent.target,
|
||||
@@ -67,14 +67,14 @@ function normalizeMouseEvent(nativeEvent) {
|
||||
screenX: nativeEvent.screenX,
|
||||
screenY: nativeEvent.screenY,
|
||||
target: nativeEvent.target,
|
||||
timestamp: nativeEvent.timestamp || Date.now()
|
||||
timestamp: Date.now()
|
||||
}]
|
||||
return {
|
||||
changedTouches: touches,
|
||||
domEvent: nativeEvent,
|
||||
identifier: touches[0].identifier,
|
||||
locationX: nativeEvent.offsetX,
|
||||
locationY: nativeEvent.offsetY,
|
||||
originalEvent: nativeEvent,
|
||||
pageX: nativeEvent.pageX,
|
||||
pageY: nativeEvent.pageY,
|
||||
target: nativeEvent.target,
|
||||
@@ -84,7 +84,8 @@ function normalizeMouseEvent(nativeEvent) {
|
||||
}
|
||||
|
||||
function normalizeNativeEvent(nativeEvent) {
|
||||
const mouse = nativeEvent.type.indexOf('mouse') >= 0
|
||||
const eventType = nativeEvent.type || (nativeEvent.originalEvent && nativeEvent.originalEvent.type) || ''
|
||||
const mouse = eventType.indexOf('mouse') >= 0
|
||||
return mouse ? normalizeMouseEvent(nativeEvent) : normalizeTouchEvent(nativeEvent)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user