react-native-gesture-handler 2.15.0 → 2.16.0-rc.0
Sign up to get free protection for your applications and to get access to all the features.
- package/RNGestureHandler.podspec +2 -23
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/swmansion/gesturehandler/RNGestureHandlerPackage.kt +9 -4
- package/android/src/main/java/com/swmansion/gesturehandler/core/FlingGestureHandler.kt +4 -0
- package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandler.kt +69 -0
- package/android/src/main/java/com/swmansion/gesturehandler/core/GestureHandlerOrchestrator.kt +25 -19
- package/android/src/main/java/com/swmansion/gesturehandler/core/LongPressGestureHandler.kt +5 -1
- package/android/src/main/java/com/swmansion/gesturehandler/core/PanGestureHandler.kt +5 -1
- package/android/src/main/java/com/swmansion/gesturehandler/core/TapGestureHandler.kt +7 -3
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerModule.kt +8 -5
- package/android/src/main/java/com/swmansion/gesturehandler/react/RNGestureHandlerRootHelper.kt +3 -2
- package/android/src/main/java/com/swmansion/gesturehandler/react/eventbuilders/GestureHandlerEventDataBuilder.kt +3 -0
- package/android/src/main/jni/cpp-adapter.cpp +18 -22
- package/apple/Handlers/RNFlingHandler.m +5 -4
- package/apple/Handlers/RNForceTouchHandler.m +3 -1
- package/apple/Handlers/RNHoverHandler.m +2 -1
- package/apple/Handlers/RNLongPressHandler.m +3 -1
- package/apple/Handlers/RNManualHandler.m +1 -0
- package/apple/Handlers/RNNativeViewHandler.mm +9 -7
- package/apple/Handlers/RNPanHandler.m +7 -2
- package/apple/Handlers/RNPinchHandler.m +38 -25
- package/apple/Handlers/RNRotationHandler.m +43 -29
- package/apple/Handlers/RNTapHandler.m +6 -4
- package/apple/RNGestureHandler.h +9 -0
- package/apple/RNGestureHandler.m +38 -3
- package/apple/RNGestureHandlerEvents.h +18 -9
- package/apple/RNGestureHandlerEvents.m +29 -11
- package/apple/RNGestureHandlerManager.h +5 -0
- package/apple/RNGestureHandlerManager.mm +32 -6
- package/apple/RNGestureHandlerModule.h +5 -3
- package/apple/RNGestureHandlerModule.mm +33 -19
- package/apple/RNGestureHandlerPointerType.h +8 -0
- package/lib/commonjs/PointerType.js +16 -0
- package/lib/commonjs/PointerType.js.map +1 -0
- package/lib/commonjs/components/GestureHandlerRootView.android.js +17 -2
- package/lib/commonjs/components/GestureHandlerRootView.android.js.map +1 -1
- package/lib/commonjs/components/GestureHandlerRootView.js +15 -2
- package/lib/commonjs/components/GestureHandlerRootView.js.map +1 -1
- package/lib/commonjs/components/GestureHandlerRootView.web.js +15 -2
- package/lib/commonjs/components/GestureHandlerRootView.web.js.map +1 -1
- package/lib/commonjs/getShadowNodeFromRef.js +19 -2
- package/lib/commonjs/getShadowNodeFromRef.js.map +1 -1
- package/lib/commonjs/handlers/createHandler.js +5 -0
- package/lib/commonjs/handlers/createHandler.js.map +1 -1
- package/lib/commonjs/handlers/gestureHandlerCommon.js.map +1 -1
- package/lib/commonjs/index.js +8 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/specs/NativeRNGestureHandlerModule.js.map +1 -1
- package/lib/commonjs/web/handlers/GestureHandler.js +6 -3
- package/lib/commonjs/web/handlers/GestureHandler.js.map +1 -1
- package/lib/commonjs/web/interfaces.js +3 -13
- package/lib/commonjs/web/interfaces.js.map +1 -1
- package/lib/commonjs/web/tools/GestureHandlerOrchestrator.js +3 -3
- package/lib/commonjs/web/tools/GestureHandlerOrchestrator.js.map +1 -1
- package/lib/commonjs/web/tools/PointerEventManager.js +29 -7
- package/lib/commonjs/web/tools/PointerEventManager.js.map +1 -1
- package/lib/commonjs/web/tools/TouchEventManager.js +3 -1
- package/lib/commonjs/web/tools/TouchEventManager.js.map +1 -1
- package/lib/commonjs/web/utils.js +6 -0
- package/lib/commonjs/web/utils.js.map +1 -1
- package/lib/module/PointerType.js +9 -0
- package/lib/module/PointerType.js.map +1 -0
- package/lib/module/components/GestureHandlerRootView.android.js +15 -2
- package/lib/module/components/GestureHandlerRootView.android.js.map +1 -1
- package/lib/module/components/GestureHandlerRootView.js +15 -3
- package/lib/module/components/GestureHandlerRootView.js.map +1 -1
- package/lib/module/components/GestureHandlerRootView.web.js +15 -3
- package/lib/module/components/GestureHandlerRootView.web.js.map +1 -1
- package/lib/module/getShadowNodeFromRef.js +19 -2
- package/lib/module/getShadowNodeFromRef.js.map +1 -1
- package/lib/module/handlers/createHandler.js +6 -1
- package/lib/module/handlers/createHandler.js.map +1 -1
- package/lib/module/handlers/gestureHandlerCommon.js.map +1 -1
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/specs/NativeRNGestureHandlerModule.js.map +1 -1
- package/lib/module/web/handlers/GestureHandler.js +5 -3
- package/lib/module/web/handlers/GestureHandler.js.map +1 -1
- package/lib/module/web/interfaces.js +2 -11
- package/lib/module/web/interfaces.js.map +1 -1
- package/lib/module/web/tools/GestureHandlerOrchestrator.js +2 -2
- package/lib/module/web/tools/GestureHandlerOrchestrator.js.map +1 -1
- package/lib/module/web/tools/PointerEventManager.js +30 -9
- package/lib/module/web/tools/PointerEventManager.js.map +1 -1
- package/lib/module/web/tools/TouchEventManager.js +2 -1
- package/lib/module/web/tools/TouchEventManager.js.map +1 -1
- package/lib/module/web/utils.js +2 -0
- package/lib/module/web/utils.js.map +1 -1
- package/lib/typescript/PointerType.d.ts +6 -0
- package/lib/typescript/components/GestureHandlerRootView.android.d.ts +1 -1
- package/lib/typescript/components/GestureHandlerRootView.d.ts +1 -1
- package/lib/typescript/components/GestureHandlerRootView.web.d.ts +1 -1
- package/lib/typescript/getShadowNodeFromRef.d.ts +1 -1
- package/lib/typescript/handlers/gestureHandlerCommon.d.ts +2 -0
- package/lib/typescript/index.d.ts +1 -0
- package/lib/typescript/specs/NativeRNGestureHandlerModule.d.ts +6 -6
- package/lib/typescript/web/handlers/GestureHandler.d.ts +2 -1
- package/lib/typescript/web/interfaces.d.ts +4 -8
- package/lib/typescript/web/utils.d.ts +2 -0
- package/package.json +1 -1
- package/src/PointerType.ts +6 -0
- package/src/components/GestureHandlerRootView.android.tsx +13 -5
- package/src/components/GestureHandlerRootView.tsx +10 -5
- package/src/components/GestureHandlerRootView.web.tsx +10 -5
- package/src/getShadowNodeFromRef.ts +28 -6
- package/src/handlers/createHandler.tsx +6 -0
- package/src/handlers/gestureHandlerCommon.ts +2 -0
- package/src/index.ts +1 -0
- package/src/specs/NativeRNGestureHandlerModule.ts +8 -8
- package/src/web/handlers/GestureHandler.ts +3 -2
- package/src/web/interfaces.ts +4 -9
- package/src/web/tools/GestureHandlerOrchestrator.ts +2 -2
- package/src/web/tools/PointerEventManager.ts +34 -14
- package/src/web/tools/TouchEventManager.ts +2 -6
- package/src/web/utils.ts +9 -0
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["TouchEventManager.ts"],"names":["EventTypes","PointerType","TouchEventType","EventManager","isPointerInBounds","TouchEventManager","setListeners","view","addEventListener","event","i","changedTouches","length","adaptedEvent","mapEvent","DOWN","x","y","touchType","markAsInBounds","pointerId","activePointersCounter","eventType","ADDITIONAL_POINTER_DOWN","onPointerAdd","onPointerDown","MOVE","inBounds","pointerIndex","pointersInBounds","indexOf","ENTER","onPointerEnter","onPointerMove","LEAVE","onPointerLeave","markAsOutOfBounds","onPointerOutOfBounds","UP","ADDITIONAL_POINTER_UP","onPointerRemove","onPointerUp","CANCEL","CANCELLED","onPointerCancel","index","touchEventType","rect","getBoundingClientRect","clientX","clientY","offsetX","left","offsetY","top","identifier","pointerType","TOUCH","time","timeStamp","allTouches","touches"],"mappings":"AAAA,SAEEA,UAFF,EAGEC,WAHF,EAIEC,cAJF,QAKO,eALP;AAMA,OAAOC,YAAP,MAAyB,gBAAzB;AACA,SAASC,iBAAT,QAAkC,UAAlC;AAEA,eAAe,MAAMC,iBAAN,SAAgCF,YAAhC,CAA0D;AAChEG,EAAAA,YAAY,GAAS;AAC1B,SAAKC,IAAL,CAAUC,gBAAV,CAA2B,YAA3B,EAA0CC,KAAD,IAAuB;AAC9D,WAAK,IAAIC,CAA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AAEA,WAAO;AACLlC,MAAAA,CAAC,EAAEiC,OADE;AAELhC,MAAAA,CAAC,EAAEiC,OAFE;AAGLC,MAAAA,OAAO,EAAEF,OAAO,GAAGF,IAAI,CAACK,IAHnB;AAILC,MAAAA,OAAO,EAAEH,OAAO,GAAGH,IAAI,CAACO,GAJnB;AAKLlC,MAAAA,SAAS,EAAEX,KAAK,CAACE,cAAN,CAAqBkC,KAArB,EAA4BU,UALlC;AAMLjC,MAAAA,SAAS,EAAEA,SANN;AAOLkC,MAAAA,WAAW,EAAEvD,WAAW,CAACwD,KAPpB;AAQLC,MAAAA,IAAI,EAAEjD,KAAK,CAACkD,SARP;AASLC,MAAAA,UAAU,EAAEnD,KAAK,CAACoD,OATb;AAULlD,MAAAA,cAAc,EAAEF,KAAK,CAACE,cAVjB;AAWLmC,MAAAA,cAAc,EAAEA;AAXX,KAAP;AAaD;;AA1JsE","sourcesContent":["import {\n AdaptedEvent,\n EventTypes,\n PointerType,\n TouchEventType,\n} from '../interfaces';\nimport EventManager from './EventManager';\nimport { isPointerInBounds } from '../utils';\n\nexport default class TouchEventManager extends EventManager<HTMLElement> {\n public setListeners(): void {\n this.view.addEventListener('touchstart', (event: TouchEvent) => {\n for (let i = 0; i < event.changedTouches.length; ++i) {\n const adaptedEvent: AdaptedEvent = this.mapEvent(\n event,\n EventTypes.DOWN,\n i,\n TouchEventType.DOWN\n );\n\n // Here we skip stylus, because in case of anything different than touch we want to handle it by using PointerEvents\n // If we leave stylus to send touch events, handlers will receive every action twice\n if (\n !isPointerInBounds(this.view, {\n x: adaptedEvent.x,\n y: adaptedEvent.y,\n }) ||\n //@ts-ignore touchType field does exist\n event.changedTouches[i].touchType === 'stylus'\n ) {\n continue;\n }\n\n this.markAsInBounds(adaptedEvent.pointerId);\n\n if (++this.activePointersCounter > 1) {\n adaptedEvent.eventType = EventTypes.ADDITIONAL_POINTER_DOWN;\n this.onPointerAdd(adaptedEvent);\n } else {\n this.onPointerDown(adaptedEvent);\n }\n }\n });\n\n this.view.addEventListener('touchmove', (event: TouchEvent) => {\n for (let i = 0; i < event.changedTouches.length; ++i) {\n const adaptedEvent: AdaptedEvent = this.mapEvent(\n event,\n EventTypes.MOVE,\n i,\n TouchEventType.MOVE\n );\n //@ts-ignore touchType field does exist\n if (event.changedTouches[i].touchType === 'stylus') {\n continue;\n }\n\n const inBounds: boolean = isPointerInBounds(this.view, {\n x: adaptedEvent.x,\n y: adaptedEvent.y,\n });\n\n const pointerIndex: number = this.pointersInBounds.indexOf(\n adaptedEvent.pointerId\n );\n\n if (inBounds) {\n if (pointerIndex < 0) {\n adaptedEvent.eventType = EventTypes.ENTER;\n this.onPointerEnter(adaptedEvent);\n this.markAsInBounds(adaptedEvent.pointerId);\n } else {\n this.onPointerMove(adaptedEvent);\n }\n } else {\n if (pointerIndex >= 0) {\n adaptedEvent.eventType = EventTypes.LEAVE;\n this.onPointerLeave(adaptedEvent);\n this.markAsOutOfBounds(adaptedEvent.pointerId);\n } else {\n this.onPointerOutOfBounds(adaptedEvent);\n }\n }\n }\n });\n\n this.view.addEventListener('touchend', (event: TouchEvent) => {\n for (let i = 0; i < event.changedTouches.length; ++i) {\n // When we call reset on gesture handlers, it also resets their event managers\n // In some handlers (like RotationGestureHandler) reset is called before all pointers leave view\n // This means, that activePointersCounter will be set to 0, while there are still remaining pointers on view\n // Removing them will end in activePointersCounter going below 0, therefore handlers won't behave properly\n if (this.activePointersCounter === 0) {\n break;\n }\n\n //@ts-ignore touchType field does exist\n if (event.changedTouches[i].touchType === 'stylus') {\n continue;\n }\n\n const adaptedEvent: AdaptedEvent = this.mapEvent(\n event,\n EventTypes.UP,\n i,\n TouchEventType.UP\n );\n\n this.markAsOutOfBounds(adaptedEvent.pointerId);\n\n if (--this.activePointersCounter > 0) {\n adaptedEvent.eventType = EventTypes.ADDITIONAL_POINTER_UP;\n this.onPointerRemove(adaptedEvent);\n } else {\n this.onPointerUp(adaptedEvent);\n }\n }\n });\n\n this.view.addEventListener('touchcancel', (event: TouchEvent) => {\n for (let i = 0; i < event.changedTouches.length; ++i) {\n const adaptedEvent: AdaptedEvent = this.mapEvent(\n event,\n EventTypes.CANCEL,\n i,\n TouchEventType.CANCELLED\n );\n\n //@ts-ignore touchType field does exist\n if (event.changedTouches[i].touchType === 'stylus') {\n continue;\n }\n\n this.onPointerCancel(adaptedEvent);\n this.markAsOutOfBounds(adaptedEvent.pointerId);\n this.activePointersCounter = 0;\n }\n });\n }\n\n protected mapEvent(\n event: TouchEvent,\n eventType: EventTypes,\n index: number,\n touchEventType: TouchEventType\n ): AdaptedEvent {\n const rect = this.view.getBoundingClientRect();\n const clientX = event.changedTouches[index].clientX;\n const clientY = event.changedTouches[index].clientY;\n\n return {\n x: clientX,\n y: clientY,\n offsetX: clientX - rect.left,\n offsetY: clientY - rect.top,\n pointerId: event.changedTouches[index].identifier,\n eventType: eventType,\n pointerType: PointerType.TOUCH,\n time: event.timeStamp,\n allTouches: event.touches,\n changedTouches: event.changedTouches,\n touchEventType: touchEventType,\n };\n }\n}\n"]}
|
1
|
+
{"version":3,"sources":["TouchEventManager.ts"],"names":["EventTypes","TouchEventType","EventManager","isPointerInBounds","PointerType","TouchEventManager","setListeners","view","addEventListener","event","i","changedTouches","length","adaptedEvent","mapEvent","DOWN","x","y","touchType","markAsInBounds","pointerId","activePointersCounter","eventType","ADDITIONAL_POINTER_DOWN","onPointerAdd","onPointerDown","MOVE","inBounds","pointerIndex","pointersInBounds","indexOf","ENTER","onPointerEnter","onPointerMove","LEAVE","onPointerLeave","markAsOutOfBounds","onPointerOutOfBounds","UP","ADDITIONAL_POINTER_UP","onPointerRemove","onPointerUp","CANCEL","CANCELLED","onPointerCancel","index","touchEventType","rect","getBoundingClientRect","clientX","clientY","offsetX","left","offsetY","top","identifier","pointerType","TOUCH","time","timeStamp","allTouches","touches"],"mappings":"AAAA,SAAuBA,UAAvB,EAAmCC,cAAnC,QAAyD,eAAzD;AACA,OAAOC,YAAP,MAAyB,gBAAzB;AACA,SAASC,i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,cAJgB,EAKF;AACd,UAAMC,IAAI,GAAG,KAAKxC,IAAL,CAAUyC,qBAAV,EAAb;AACA,UAAMC,OAAO,GAAGxC,KAAK,CAACE,cAAN,CAAqBkC,KAArB,EAA4BI,OAA5C;AACA,UAAMC,OAAO,GAAGzC,KAAK,CAACE,cAAN,CAAqBkC,KAArB,EAA4BK,OAA5C;AAEA,WAAO;AACLlC,MAAAA,CAAC,EAAEiC,OADE;AAELhC,MAAAA,CAAC,EAAEiC,OAFE;AAGLC,MAAAA,OAAO,EAAEF,OAAO,GAAGF,IAAI,CAACK,IAHnB;AAILC,MAAAA,OAAO,EAAEH,OAAO,GAAGH,IAAI,CAACO,GAJnB;AAKLlC,MAAAA,SAAS,EAAEX,KAAK,CAACE,cAAN,CAAqBkC,KAArB,EAA4BU,UALlC;AAMLjC,MAAAA,SAAS,EAAEA,SANN;AAOLkC,MAAAA,WAAW,EAAEpD,WAAW,CAACqD,KAPpB;AAQLC,MAAAA,IAAI,EAAEjD,KAAK,CAACkD,SARP;AASLC,MAAAA,UAAU,EAAEnD,KAAK,CAACoD,OATb;AAULlD,MAAAA,cAAc,EAAEF,KAAK,CAACE,cAVjB;AAWLmC,MAAAA,cAAc,EAAEA;AAXX,KAAP;AAaD;;AA1JsE","sourcesContent":["import { AdaptedEvent, EventTypes, TouchEventType } from '../interfaces';\nimport EventManager from './EventManager';\nimport { isPointerInBounds } from '../utils';\nimport { PointerType } from '../../PointerType';\n\nexport default class TouchEventManager extends EventManager<HTMLElement> {\n public setListeners(): void {\n this.view.addEventListener('touchstart', (event: TouchEvent) => {\n for (let i = 0; i < event.changedTouches.length; ++i) {\n const adaptedEvent: AdaptedEvent = this.mapEvent(\n event,\n EventTypes.DOWN,\n i,\n TouchEventType.DOWN\n );\n\n // Here we skip stylus, because in case of anything different than touch we want to handle it by using PointerEvents\n // If we leave stylus to send touch events, handlers will receive every action twice\n if (\n !isPointerInBounds(this.view, {\n x: adaptedEvent.x,\n y: adaptedEvent.y,\n }) ||\n //@ts-ignore touchType field does exist\n event.changedTouches[i].touchType === 'stylus'\n ) {\n continue;\n }\n\n this.markAsInBounds(adaptedEvent.pointerId);\n\n if (++this.activePointersCounter > 1) {\n adaptedEvent.eventType = EventTypes.ADDITIONAL_POINTER_DOWN;\n this.onPointerAdd(adaptedEvent);\n } else {\n this.onPointerDown(adaptedEvent);\n }\n }\n });\n\n this.view.addEventListener('touchmove', (event: TouchEvent) => {\n for (let i = 0; i < event.changedTouches.length; ++i) {\n const adaptedEvent: AdaptedEvent = this.mapEvent(\n event,\n EventTypes.MOVE,\n i,\n TouchEventType.MOVE\n );\n //@ts-ignore touchType field does exist\n if (event.changedTouches[i].touchType === 'stylus') {\n continue;\n }\n\n const inBounds: boolean = isPointerInBounds(this.view, {\n x: adaptedEvent.x,\n y: adaptedEvent.y,\n });\n\n const pointerIndex: number = this.pointersInBounds.indexOf(\n adaptedEvent.pointerId\n );\n\n if (inBounds) {\n if (pointerIndex < 0) {\n adaptedEvent.eventType = EventTypes.ENTER;\n this.onPointerEnter(adaptedEvent);\n this.markAsInBounds(adaptedEvent.pointerId);\n } else {\n this.onPointerMove(adaptedEvent);\n }\n } else {\n if (pointerIndex >= 0) {\n adaptedEvent.eventType = EventTypes.LEAVE;\n this.onPointerLeave(adaptedEvent);\n this.markAsOutOfBounds(adaptedEvent.pointerId);\n } else {\n this.onPointerOutOfBounds(adaptedEvent);\n }\n }\n }\n });\n\n this.view.addEventListener('touchend', (event: TouchEvent) => {\n for (let i = 0; i < event.changedTouches.length; ++i) {\n // When we call reset on gesture handlers, it also resets their event managers\n // In some handlers (like RotationGestureHandler) reset is called before all pointers leave view\n // This means, that activePointersCounter will be set to 0, while there are still remaining pointers on view\n // Removing them will end in activePointersCounter going below 0, therefore handlers won't behave properly\n if (this.activePointersCounter === 0) {\n break;\n }\n\n //@ts-ignore touchType field does exist\n if (event.changedTouches[i].touchType === 'stylus') {\n continue;\n }\n\n const adaptedEvent: AdaptedEvent = this.mapEvent(\n event,\n EventTypes.UP,\n i,\n TouchEventType.UP\n );\n\n this.markAsOutOfBounds(adaptedEvent.pointerId);\n\n if (--this.activePointersCounter > 0) {\n adaptedEvent.eventType = EventTypes.ADDITIONAL_POINTER_UP;\n this.onPointerRemove(adaptedEvent);\n } else {\n this.onPointerUp(adaptedEvent);\n }\n }\n });\n\n this.view.addEventListener('touchcancel', (event: TouchEvent) => {\n for (let i = 0; i < event.changedTouches.length; ++i) {\n const adaptedEvent: AdaptedEvent = this.mapEvent(\n event,\n EventTypes.CANCEL,\n i,\n TouchEventType.CANCELLED\n );\n\n //@ts-ignore touchType field does exist\n if (event.changedTouches[i].touchType === 'stylus') {\n continue;\n }\n\n this.onPointerCancel(adaptedEvent);\n this.markAsOutOfBounds(adaptedEvent.pointerId);\n this.activePointersCounter = 0;\n }\n });\n }\n\n protected mapEvent(\n event: TouchEvent,\n eventType: EventTypes,\n index: number,\n touchEventType: TouchEventType\n ): AdaptedEvent {\n const rect = this.view.getBoundingClientRect();\n const clientX = event.changedTouches[index].clientX;\n const clientY = event.changedTouches[index].clientY;\n\n return {\n x: clientX,\n y: clientY,\n offsetX: clientX - rect.left,\n offsetY: clientY - rect.top,\n pointerId: event.changedTouches[index].identifier,\n eventType: eventType,\n pointerType: PointerType.TOUCH,\n time: event.timeStamp,\n allTouches: event.touches,\n changedTouches: event.changedTouches,\n touchEventType: touchEventType,\n };\n }\n}\n"]}
|
package/lib/module/web/utils.js
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import { PointerType } from '../PointerType';
|
1
2
|
export function isPointerInBounds(view, {
|
2
3
|
x,
|
3
4
|
y
|
@@ -5,4 +6,5 @@ export function isPointerInBounds(view, {
|
|
5
6
|
const rect = view.getBoundingClientRect();
|
6
7
|
return x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom;
|
7
8
|
}
|
9
|
+
export const PointerTypeMapping = new Map([['mouse', PointerType.MOUSE], ['touch', PointerType.TOUCH], ['pen', PointerType.STYLUS], ['none', PointerType.OTHER]]);
|
8
10
|
//# sourceMappingURL=utils.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["utils.ts"],"names":["isPointerInBounds","view","x","y","rect","getBoundingClientRect","left","right","top","bottom"],"mappings":"AAAA,OAAO,
|
1
|
+
{"version":3,"sources":["utils.ts"],"names":["PointerType","isPointerInBounds","view","x","y","rect","getBoundingClientRect","left","right","top","bottom","PointerTypeMapping","Map","MOUSE","TOUCH","STYLUS","OTHER"],"mappings":"AAAA,SAASA,WAAT,QAA4B,gBAA5B;AAEA,OAAO,SAASC,iBAAT,CACLC,IADK,EAEL;AAAEC,EAAAA,CAAF;AAAKC,EAAAA;AAAL,CAFK,EAGI;AACT,QAAMC,IAAa,GAAGH,IAAI,CAACI,qBAAL,EAAtB;AAEA,SAAOH,CAAC,IAAIE,IAAI,CAACE,IAAV,IAAkBJ,CAAC,IAAIE,IAAI,CAACG,KAA5B,IAAqCJ,CAAC,IAAIC,IAAI,CAACI,GAA/C,IAAsDL,CAAC,IAAIC,IAAI,CAACK,MAAvE;AACD;AAED,OAAO,MAAMC,kBAAkB,GAAG,IAAIC,GAAJ,CAA6B,CAC7D,CAAC,OAAD,EAAUZ,WAAW,CAACa,KAAtB,CAD6D,EAE7D,CAAC,OAAD,EAAUb,WAAW,CAACc,KAAtB,CAF6D,EAG7D,CAAC,KAAD,EAAQd,WAAW,CAACe,MAApB,CAH6D,EAI7D,CAAC,MAAD,EAASf,WAAW,CAACgB,KAArB,CAJ6D,CAA7B,CAA3B","sourcesContent":["import { PointerType } from '../PointerType';\n\nexport function isPointerInBounds(\n view: HTMLElement,\n { x, y }: { x: number; y: number }\n): boolean {\n const rect: DOMRect = view.getBoundingClientRect();\n\n return x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom;\n}\n\nexport const PointerTypeMapping = new Map<string, PointerType>([\n ['mouse', PointerType.MOUSE],\n ['touch', PointerType.TOUCH],\n ['pen', PointerType.STYLUS],\n ['none', PointerType.OTHER],\n]);\n"]}
|
@@ -3,4 +3,4 @@ import { PropsWithChildren } from 'react';
|
|
3
3
|
import { ViewProps } from 'react-native';
|
4
4
|
export interface GestureHandlerRootViewProps extends PropsWithChildren<ViewProps> {
|
5
5
|
}
|
6
|
-
export default function GestureHandlerRootView(
|
6
|
+
export default function GestureHandlerRootView({ style, ...rest }: GestureHandlerRootViewProps): React.JSX.Element;
|
@@ -3,4 +3,4 @@ import { PropsWithChildren } from 'react';
|
|
3
3
|
import { ViewProps } from 'react-native';
|
4
4
|
export interface GestureHandlerRootViewProps extends PropsWithChildren<ViewProps> {
|
5
5
|
}
|
6
|
-
export default function GestureHandlerRootView(
|
6
|
+
export default function GestureHandlerRootView({ style, ...rest }: GestureHandlerRootViewProps): React.JSX.Element;
|
@@ -3,4 +3,4 @@ import { PropsWithChildren } from 'react';
|
|
3
3
|
import { ViewProps } from 'react-native';
|
4
4
|
export interface GestureHandlerRootViewProps extends PropsWithChildren<ViewProps> {
|
5
5
|
}
|
6
|
-
export default function GestureHandlerRootView(
|
6
|
+
export default function GestureHandlerRootView({ style, ...rest }: GestureHandlerRootViewProps): React.JSX.Element;
|
@@ -1 +1 @@
|
|
1
|
-
export declare function getShadowNodeFromRef(ref:
|
1
|
+
export declare function getShadowNodeFromRef(ref: unknown): unknown;
|
@@ -3,12 +3,14 @@ import { State } from '../State';
|
|
3
3
|
import { TouchEventType } from '../TouchEventType';
|
4
4
|
import { ValueOf } from '../typeUtils';
|
5
5
|
import { MouseButton } from '../web/interfaces';
|
6
|
+
import { PointerType } from '../PointerType';
|
6
7
|
export declare const baseGestureHandlerProps: readonly ["id", "enabled", "shouldCancelWhenOutside", "hitSlop", "cancelsTouchesInView", "userSelect", "activeCursor", "mouseButton", "enableContextMenu", "waitFor", "simultaneousHandlers", "blocksHandlers", "onBegan", "onFailed", "onCancelled", "onActivated", "onEnded", "onGestureEvent", "onHandlerStateChange"];
|
7
8
|
export declare const baseGestureHandlerWithMonitorProps: string[];
|
8
9
|
export interface GestureEventPayload {
|
9
10
|
handlerTag: number;
|
10
11
|
numberOfPointers: number;
|
11
12
|
state: ValueOf<typeof State>;
|
13
|
+
pointerType: PointerType;
|
12
14
|
}
|
13
15
|
export interface HandlerStateChangeEventPayload extends GestureEventPayload {
|
14
16
|
oldState: ValueOf<typeof State>;
|
@@ -1,6 +1,7 @@
|
|
1
1
|
export { Directions } from './Directions';
|
2
2
|
export { State } from './State';
|
3
3
|
export { MouseButton } from './web/interfaces';
|
4
|
+
export { PointerType } from './PointerType';
|
4
5
|
export { default as gestureHandlerRootHOC } from './components/gestureHandlerRootHOC';
|
5
6
|
export { default as GestureHandlerRootView } from './components/GestureHandlerRootView';
|
6
7
|
export type { GestureEvent, HandlerStateChangeEvent, GestureEventPayload, HandlerStateChangeEventPayload, GestureTouchEvent, TouchData, GestureUpdateEvent, GestureStateChangeEvent, } from './handlers/gestureHandlerCommon';
|
@@ -1,12 +1,12 @@
|
|
1
1
|
import { TurboModule } from 'react-native';
|
2
|
-
import {
|
2
|
+
import { Double } from 'react-native/Libraries/Types/CodegenTypes';
|
3
3
|
export interface Spec extends TurboModule {
|
4
|
-
handleSetJSResponder: (tag:
|
4
|
+
handleSetJSResponder: (tag: Double, blockNativeResponder: boolean) => void;
|
5
5
|
handleClearJSResponder: () => void;
|
6
|
-
createGestureHandler: (handlerName: string, handlerTag:
|
7
|
-
attachGestureHandler: (handlerTag:
|
8
|
-
updateGestureHandler: (handlerTag:
|
9
|
-
dropGestureHandler: (handlerTag:
|
6
|
+
createGestureHandler: (handlerName: string, handlerTag: Double, config: Object) => void;
|
7
|
+
attachGestureHandler: (handlerTag: Double, newView: Double, actionType: Double) => void;
|
8
|
+
updateGestureHandler: (handlerTag: Double, newConfig: Object) => void;
|
9
|
+
dropGestureHandler: (handlerTag: Double) => void;
|
10
10
|
install: () => boolean;
|
11
11
|
flushOperations: () => void;
|
12
12
|
}
|
@@ -1,8 +1,9 @@
|
|
1
1
|
import { State } from '../../State';
|
2
|
-
import { Config, AdaptedEvent,
|
2
|
+
import { Config, AdaptedEvent, MouseButton } from '../interfaces';
|
3
3
|
import EventManager from '../tools/EventManager';
|
4
4
|
import PointerTracker from '../tools/PointerTracker';
|
5
5
|
import { GestureHandlerDelegate } from '../tools/GestureHandlerDelegate';
|
6
|
+
import { PointerType } from '../../PointerType';
|
6
7
|
export default abstract class GestureHandler {
|
7
8
|
private lastSentState;
|
8
9
|
protected currentState: State;
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import { UserSelect, ActiveCursor } from '../handlers/gestureHandlerCommon';
|
2
2
|
import { Directions } from '../Directions';
|
3
3
|
import { State } from '../State';
|
4
|
+
import { PointerType } from '../PointerType';
|
4
5
|
export interface HitSlop {
|
5
6
|
left?: number;
|
6
7
|
right?: number;
|
@@ -64,6 +65,7 @@ interface NativeEvent extends Record<string, NativeEventArgs> {
|
|
64
65
|
handlerTag: number;
|
65
66
|
target: number;
|
66
67
|
oldState?: State;
|
68
|
+
pointerType: PointerType;
|
67
69
|
}
|
68
70
|
export interface PointerData {
|
69
71
|
id: number;
|
@@ -109,8 +111,8 @@ export interface AdaptedEvent {
|
|
109
111
|
}
|
110
112
|
export declare enum MouseButton {
|
111
113
|
LEFT = 1,
|
112
|
-
|
113
|
-
|
114
|
+
RIGHT = 2,
|
115
|
+
MIDDLE = 4,
|
114
116
|
BUTTON_4 = 8,
|
115
117
|
BUTTON_5 = 16,
|
116
118
|
ALL = 31
|
@@ -132,10 +134,4 @@ export declare enum TouchEventType {
|
|
132
134
|
UP = 3,
|
133
135
|
CANCELLED = 4
|
134
136
|
}
|
135
|
-
export declare enum PointerType {
|
136
|
-
NONE = "none",
|
137
|
-
MOUSE = "mouse",
|
138
|
-
TOUCH = "touch",
|
139
|
-
PEN = "pen"
|
140
|
-
}
|
141
137
|
export {};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import * as React from 'react';
|
2
2
|
import { PropsWithChildren } from 'react';
|
3
|
-
import { ViewProps } from 'react-native';
|
3
|
+
import { ViewProps, StyleSheet } from 'react-native';
|
4
4
|
import { maybeInitializeFabric } from '../init';
|
5
5
|
import GestureHandlerRootViewContext from '../GestureHandlerRootViewContext';
|
6
6
|
import GestureHandlerRootViewNativeComponent from '../specs/RNGestureHandlerRootViewNativeComponent';
|
@@ -8,9 +8,10 @@ import GestureHandlerRootViewNativeComponent from '../specs/RNGestureHandlerRoot
|
|
8
8
|
export interface GestureHandlerRootViewProps
|
9
9
|
extends PropsWithChildren<ViewProps> {}
|
10
10
|
|
11
|
-
export default function GestureHandlerRootView(
|
12
|
-
|
13
|
-
|
11
|
+
export default function GestureHandlerRootView({
|
12
|
+
style,
|
13
|
+
...rest
|
14
|
+
}: GestureHandlerRootViewProps) {
|
14
15
|
// try initialize fabric on the first render, at this point we can
|
15
16
|
// reliably check if fabric is enabled (the function contains a flag
|
16
17
|
// to make sure it's called only once)
|
@@ -18,7 +19,14 @@ export default function GestureHandlerRootView(
|
|
18
19
|
|
19
20
|
return (
|
20
21
|
<GestureHandlerRootViewContext.Provider value>
|
21
|
-
<GestureHandlerRootViewNativeComponent
|
22
|
+
<GestureHandlerRootViewNativeComponent
|
23
|
+
style={style ?? styles.container}
|
24
|
+
{...rest}
|
25
|
+
/>
|
22
26
|
</GestureHandlerRootViewContext.Provider>
|
23
27
|
);
|
24
28
|
}
|
29
|
+
|
30
|
+
const styles = StyleSheet.create({
|
31
|
+
container: { flex: 1 },
|
32
|
+
});
|
@@ -1,15 +1,16 @@
|
|
1
1
|
import * as React from 'react';
|
2
2
|
import { PropsWithChildren } from 'react';
|
3
|
-
import { View, ViewProps } from 'react-native';
|
3
|
+
import { View, ViewProps, StyleSheet } from 'react-native';
|
4
4
|
import { maybeInitializeFabric } from '../init';
|
5
5
|
import GestureHandlerRootViewContext from '../GestureHandlerRootViewContext';
|
6
6
|
|
7
7
|
export interface GestureHandlerRootViewProps
|
8
8
|
extends PropsWithChildren<ViewProps> {}
|
9
9
|
|
10
|
-
export default function GestureHandlerRootView(
|
11
|
-
|
12
|
-
|
10
|
+
export default function GestureHandlerRootView({
|
11
|
+
style,
|
12
|
+
...rest
|
13
|
+
}: GestureHandlerRootViewProps) {
|
13
14
|
// try initialize fabric on the first render, at this point we can
|
14
15
|
// reliably check if fabric is enabled (the function contains a flag
|
15
16
|
// to make sure it's called only once)
|
@@ -17,7 +18,11 @@ export default function GestureHandlerRootView(
|
|
17
18
|
|
18
19
|
return (
|
19
20
|
<GestureHandlerRootViewContext.Provider value>
|
20
|
-
<View {...
|
21
|
+
<View style={style ?? styles.container} {...rest} />
|
21
22
|
</GestureHandlerRootViewContext.Provider>
|
22
23
|
);
|
23
24
|
}
|
25
|
+
|
26
|
+
const styles = StyleSheet.create({
|
27
|
+
container: { flex: 1 },
|
28
|
+
});
|
@@ -1,17 +1,22 @@
|
|
1
1
|
import * as React from 'react';
|
2
2
|
import { PropsWithChildren } from 'react';
|
3
|
-
import { View, ViewProps } from 'react-native';
|
3
|
+
import { View, ViewProps, StyleSheet } from 'react-native';
|
4
4
|
import GestureHandlerRootViewContext from '../GestureHandlerRootViewContext';
|
5
5
|
|
6
6
|
export interface GestureHandlerRootViewProps
|
7
7
|
extends PropsWithChildren<ViewProps> {}
|
8
8
|
|
9
|
-
export default function GestureHandlerRootView(
|
10
|
-
|
11
|
-
|
9
|
+
export default function GestureHandlerRootView({
|
10
|
+
style,
|
11
|
+
...rest
|
12
|
+
}: GestureHandlerRootViewProps) {
|
12
13
|
return (
|
13
14
|
<GestureHandlerRootViewContext.Provider value>
|
14
|
-
<View {...
|
15
|
+
<View style={style ?? styles.container} {...rest} />
|
15
16
|
</GestureHandlerRootViewContext.Provider>
|
16
17
|
);
|
17
18
|
}
|
19
|
+
|
20
|
+
const styles = StyleSheet.create({
|
21
|
+
container: { flex: 1 },
|
22
|
+
});
|
@@ -2,21 +2,43 @@
|
|
2
2
|
// attached view may get flattened on Fabric. This implementation causes errors
|
3
3
|
// on web due to the static resolution of `require` statements by webpack breaking
|
4
4
|
// the conditional importing. Solved by making .web file.
|
5
|
-
let findHostInstance_DEPRECATED: (ref:
|
5
|
+
let findHostInstance_DEPRECATED: (ref: unknown) => void;
|
6
|
+
let getInternalInstanceHandleFromPublicInstance: (ref: unknown) => {
|
7
|
+
stateNode: { node: unknown };
|
8
|
+
};
|
6
9
|
|
7
|
-
export function getShadowNodeFromRef(ref:
|
10
|
+
export function getShadowNodeFromRef(ref: unknown) {
|
8
11
|
// load findHostInstance_DEPRECATED lazily because it may not be available before render
|
9
12
|
if (findHostInstance_DEPRECATED === undefined) {
|
10
13
|
try {
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
11
15
|
findHostInstance_DEPRECATED =
|
12
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-unsafe-member-access
|
13
17
|
require('react-native/Libraries/Renderer/shims/ReactFabric').findHostInstance_DEPRECATED;
|
14
18
|
} catch (e) {
|
15
|
-
findHostInstance_DEPRECATED = (_ref:
|
19
|
+
findHostInstance_DEPRECATED = (_ref: unknown) => null;
|
20
|
+
}
|
21
|
+
}
|
22
|
+
|
23
|
+
// load findHostInstance_DEPRECATED lazily because it may not be available before render
|
24
|
+
if (getInternalInstanceHandleFromPublicInstance === undefined) {
|
25
|
+
try {
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
27
|
+
getInternalInstanceHandleFromPublicInstance =
|
28
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-unsafe-member-access
|
29
|
+
require('react-native/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance')
|
30
|
+
.getInternalInstanceHandleFromPublicInstance ??
|
31
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return
|
32
|
+
((ref: any) => ref._internalInstanceHandle);
|
33
|
+
} catch (e) {
|
34
|
+
getInternalInstanceHandleFromPublicInstance = (ref: any) =>
|
35
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return
|
36
|
+
ref._internalInstanceHandle;
|
16
37
|
}
|
17
38
|
}
|
18
39
|
|
19
40
|
// @ts-ignore Fabric
|
20
|
-
return
|
21
|
-
|
41
|
+
return getInternalInstanceHandleFromPublicInstance(
|
42
|
+
findHostInstance_DEPRECATED(ref)
|
43
|
+
).stateNode.node;
|
22
44
|
}
|
@@ -5,6 +5,8 @@ import {
|
|
5
5
|
DeviceEventEmitter,
|
6
6
|
EmitterSubscription,
|
7
7
|
} from 'react-native';
|
8
|
+
// @ts-ignore - its taken straight from RN
|
9
|
+
import { customDirectEventTypes } from 'react-native/Libraries/Renderer/shims/ReactNativeViewConfigRegistry';
|
8
10
|
// @ts-ignore - it isn't typed by TS & don't have definitelyTyped types
|
9
11
|
import deepEqual from 'lodash/isEqual';
|
10
12
|
import RNGestureHandlerModule from '../RNGestureHandlerModule';
|
@@ -33,6 +35,10 @@ import { ghQueueMicrotask } from '../ghQueueMicrotask';
|
|
33
35
|
|
34
36
|
const UIManagerAny = UIManager as any;
|
35
37
|
|
38
|
+
customDirectEventTypes.topGestureHandlerEvent = {
|
39
|
+
registrationName: 'onGestureHandlerEvent',
|
40
|
+
};
|
41
|
+
|
36
42
|
const customGHEventsConfigFabricAndroid = {
|
37
43
|
topOnGestureHandlerEvent: { registrationName: 'onGestureHandlerEvent' },
|
38
44
|
topOnGestureHandlerStateChange: {
|
@@ -13,6 +13,7 @@ import { toArray } from '../utils';
|
|
13
13
|
import RNGestureHandlerModule from '../RNGestureHandlerModule';
|
14
14
|
import { ghQueueMicrotask } from '../ghQueueMicrotask';
|
15
15
|
import { MouseButton } from '../web/interfaces';
|
16
|
+
import { PointerType } from '../PointerType';
|
16
17
|
|
17
18
|
const commonProps = [
|
18
19
|
'id',
|
@@ -54,6 +55,7 @@ export interface GestureEventPayload {
|
|
54
55
|
handlerTag: number;
|
55
56
|
numberOfPointers: number;
|
56
57
|
state: ValueOf<typeof State>;
|
58
|
+
pointerType: PointerType;
|
57
59
|
}
|
58
60
|
export interface HandlerStateChangeEventPayload extends GestureEventPayload {
|
59
61
|
oldState: ValueOf<typeof State>;
|
package/src/index.ts
CHANGED
@@ -3,6 +3,7 @@ import { initialize } from './init';
|
|
3
3
|
export { Directions } from './Directions';
|
4
4
|
export { State } from './State';
|
5
5
|
export { MouseButton } from './web/interfaces';
|
6
|
+
export { PointerType } from './PointerType';
|
6
7
|
export { default as gestureHandlerRootHOC } from './components/gestureHandlerRootHOC';
|
7
8
|
export { default as GestureHandlerRootView } from './components/GestureHandlerRootView';
|
8
9
|
export type {
|
@@ -1,24 +1,24 @@
|
|
1
1
|
import { TurboModuleRegistry, TurboModule } from 'react-native';
|
2
|
-
import {
|
2
|
+
import { Double } from 'react-native/Libraries/Types/CodegenTypes';
|
3
3
|
|
4
4
|
export interface Spec extends TurboModule {
|
5
|
-
handleSetJSResponder: (tag:
|
5
|
+
handleSetJSResponder: (tag: Double, blockNativeResponder: boolean) => void;
|
6
6
|
handleClearJSResponder: () => void;
|
7
7
|
createGestureHandler: (
|
8
8
|
handlerName: string,
|
9
|
-
handlerTag:
|
9
|
+
handlerTag: Double,
|
10
10
|
// Record<> is not supported by codegen
|
11
11
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
12
12
|
config: Object
|
13
13
|
) => void;
|
14
14
|
attachGestureHandler: (
|
15
|
-
handlerTag:
|
16
|
-
newView:
|
17
|
-
actionType:
|
15
|
+
handlerTag: Double,
|
16
|
+
newView: Double,
|
17
|
+
actionType: Double
|
18
18
|
) => void;
|
19
19
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
20
|
-
updateGestureHandler: (handlerTag:
|
21
|
-
dropGestureHandler: (handlerTag:
|
20
|
+
updateGestureHandler: (handlerTag: Double, newConfig: Object) => void;
|
21
|
+
dropGestureHandler: (handlerTag: Double) => void;
|
22
22
|
install: () => boolean;
|
23
23
|
flushOperations: () => void;
|
24
24
|
}
|
@@ -7,7 +7,6 @@ import {
|
|
7
7
|
ResultEvent,
|
8
8
|
PointerData,
|
9
9
|
ResultTouchEvent,
|
10
|
-
PointerType,
|
11
10
|
TouchEventType,
|
12
11
|
EventTypes,
|
13
12
|
MouseButton,
|
@@ -17,6 +16,7 @@ import GestureHandlerOrchestrator from '../tools/GestureHandlerOrchestrator';
|
|
17
16
|
import InteractionManager from '../tools/InteractionManager';
|
18
17
|
import PointerTracker, { TrackerElement } from '../tools/PointerTracker';
|
19
18
|
import { GestureHandlerDelegate } from '../tools/GestureHandlerDelegate';
|
19
|
+
import { PointerType } from '../../PointerType';
|
20
20
|
|
21
21
|
export default abstract class GestureHandler {
|
22
22
|
private lastSentState: State | null = null;
|
@@ -38,7 +38,7 @@ export default abstract class GestureHandler {
|
|
38
38
|
protected awaiting = false;
|
39
39
|
protected active = false;
|
40
40
|
protected shouldResetProgress = false;
|
41
|
-
protected pointerType: PointerType = PointerType.
|
41
|
+
protected pointerType: PointerType = PointerType.MOUSE;
|
42
42
|
|
43
43
|
protected delegate: GestureHandlerDelegate<unknown>;
|
44
44
|
|
@@ -421,6 +421,7 @@ export default abstract class GestureHandler {
|
|
421
421
|
handlerTag: this.handlerTag,
|
422
422
|
target: this.viewRef,
|
423
423
|
oldState: newState !== oldState ? oldState : undefined,
|
424
|
+
pointerType: this.pointerType,
|
424
425
|
},
|
425
426
|
timeStamp: Date.now(),
|
426
427
|
};
|
package/src/web/interfaces.ts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import { UserSelect, ActiveCursor } from '../handlers/gestureHandlerCommon';
|
2
2
|
import { Directions } from '../Directions';
|
3
3
|
import { State } from '../State';
|
4
|
+
import { PointerType } from '../PointerType';
|
4
5
|
|
5
6
|
export interface HitSlop {
|
6
7
|
left?: number;
|
@@ -79,6 +80,7 @@ interface NativeEvent extends Record<string, NativeEventArgs> {
|
|
79
80
|
handlerTag: number;
|
80
81
|
target: number;
|
81
82
|
oldState?: State;
|
83
|
+
pointerType: PointerType;
|
82
84
|
}
|
83
85
|
|
84
86
|
export interface PointerData {
|
@@ -133,8 +135,8 @@ export interface AdaptedEvent {
|
|
133
135
|
|
134
136
|
export enum MouseButton {
|
135
137
|
LEFT = 1,
|
136
|
-
|
137
|
-
|
138
|
+
RIGHT = 2,
|
139
|
+
MIDDLE = 4,
|
138
140
|
BUTTON_4 = 8,
|
139
141
|
BUTTON_5 = 16,
|
140
142
|
ALL = 31,
|
@@ -158,10 +160,3 @@ export enum TouchEventType {
|
|
158
160
|
UP,
|
159
161
|
CANCELLED,
|
160
162
|
}
|
161
|
-
|
162
|
-
export enum PointerType {
|
163
|
-
NONE = 'none',
|
164
|
-
MOUSE = 'mouse',
|
165
|
-
TOUCH = 'touch',
|
166
|
-
PEN = 'pen',
|
167
|
-
}
|
@@ -1,5 +1,5 @@
|
|
1
|
+
import { PointerType } from '../../PointerType';
|
1
2
|
import { State } from '../../State';
|
2
|
-
import { PointerType } from '../interfaces';
|
3
3
|
|
4
4
|
import GestureHandler from '../handlers/GestureHandler';
|
5
5
|
import PointerTracker from './PointerTracker';
|
@@ -359,7 +359,7 @@ export default class GestureHandlerOrchestrator {
|
|
359
359
|
this.gestureHandlers.forEach((handler: GestureHandler) => {
|
360
360
|
if (
|
361
361
|
handler.getPointerType() !== PointerType.MOUSE &&
|
362
|
-
handler.getPointerType() !== PointerType.
|
362
|
+
handler.getPointerType() !== PointerType.STYLUS
|
363
363
|
) {
|
364
364
|
return;
|
365
365
|
}
|