File tree Expand file tree Collapse file tree 1 file changed +18
-6
lines changed Expand file tree Collapse file tree 1 file changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -60,21 +60,31 @@ const SensorInput = ({
60
60
}
61
61
}
62
62
} ;
63
+ const mouseDownTouchStartAction = ( ) => {
64
+ setMouseDown ( true ) ;
65
+ handleSensorChange ( sensor . max ) ;
66
+ } ;
67
+ const mouseUpTouchEndAction = ( ) => {
68
+ if ( mouseDown ) {
69
+ setMouseDown ( false ) ;
70
+ handleSensorChange ( sensor . min ) ;
71
+ }
72
+ } ;
63
73
const mouseDownListener = (
64
74
event : React . MouseEvent < HTMLButtonElement , MouseEvent >
65
75
) => {
66
76
event . preventDefault ( ) ;
67
- setMouseDown ( true ) ;
68
- handleSensorChange ( sensor . max ) ;
77
+ mouseDownTouchStartAction ( ) ;
69
78
} ;
70
79
const mouseUpListener = (
71
80
event : React . MouseEvent < HTMLButtonElement , MouseEvent >
72
81
) => {
73
82
event . preventDefault ( ) ;
74
- if ( mouseDown ) {
75
- setMouseDown ( false ) ;
76
- handleSensorChange ( sensor . min ) ;
77
- }
83
+ mouseUpTouchEndAction ( ) ;
84
+ } ;
85
+ const touchEndListener = ( event : React . TouchEvent ) => {
86
+ event . preventDefault ( ) ;
87
+ mouseUpTouchEndAction ( ) ;
78
88
} ;
79
89
const mouseLeaveListener = ( ) => {
80
90
if ( mouseDown ) {
@@ -124,7 +134,9 @@ const SensorInput = ({
124
134
onKeyDown = { keyListener }
125
135
onKeyUp = { keyListener }
126
136
onMouseDown = { mouseDownListener }
137
+ onTouchStart = { mouseDownTouchStartAction }
127
138
onMouseUp = { mouseUpListener }
139
+ onTouchEnd = { touchEndListener }
128
140
onMouseLeave = { mouseLeaveListener }
129
141
>
130
142
{ logo ? (
You can’t perform that action at this time.
0 commit comments