We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a313a02 commit 0fc45d8Copy full SHA for 0fc45d8
1 file changed
src/helpers/utils/getDeviceEventNames.ts
@@ -0,0 +1,26 @@
1
+type moveEvents = 'touchmove' | 'mousemove';
2
+type upEvents = 'touchend' | 'mouseup';
3
+
4
+interface returnProp {
5
+ move: moveEvents;
6
+ up: upEvents;
7
+}
8
9
+const getDeviceEventNames = (): returnProp => {
10
+ if (isTouchDevice()) {
11
+ return {
12
+ move: 'touchmove',
13
+ up: 'touchend'
14
+ };
15
+ }
16
17
+ move: 'mousemove',
18
+ up: 'mouseup'
19
20
+};
21
22
+const isTouchDevice = () => {
23
+ return 'ontouchstart' in window || navigator.maxTouchPoints;
24
25
26
+export default getDeviceEventNames;
0 commit comments