Skip to content

Commit 0fc45d8

Browse files
committed
fix: slider issue fix on mobile
1 parent a313a02 commit 0fc45d8

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
return {
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

Comments
 (0)