@@ -116,9 +116,13 @@ export function useColorWheel(props: ColorWheelAriaProps, state: ColorWheelState
116
116
currentPointer . current = id ;
117
117
focusInput ( ) ;
118
118
state . setDragging ( true ) ;
119
- addGlobalListener ( window , 'mouseup' , onThumbUp , false ) ;
120
- addGlobalListener ( window , 'touchend' , onThumbUp , false ) ;
121
- addGlobalListener ( window , 'pointerup' , onThumbUp , false ) ;
119
+
120
+ if ( typeof PointerEvent !== 'undefined' ) {
121
+ addGlobalListener ( window , 'pointerup' , onThumbUp , false ) ;
122
+ } else {
123
+ addGlobalListener ( window , 'mouseup' , onThumbUp , false ) ;
124
+ addGlobalListener ( window , 'touchend' , onThumbUp , false ) ;
125
+ }
122
126
}
123
127
} ;
124
128
@@ -130,9 +134,12 @@ export function useColorWheel(props: ColorWheelAriaProps, state: ColorWheelState
130
134
currentPointer . current = undefined ;
131
135
isOnTrack . current = false ;
132
136
133
- removeGlobalListener ( window , 'mouseup' , onThumbUp , false ) ;
134
- removeGlobalListener ( window , 'touchend' , onThumbUp , false ) ;
135
- removeGlobalListener ( window , 'pointerup' , onThumbUp , false ) ;
137
+ if ( typeof PointerEvent !== 'undefined' ) {
138
+ removeGlobalListener ( window , 'pointerup' , onThumbUp , false ) ;
139
+ } else {
140
+ removeGlobalListener ( window , 'mouseup' , onThumbUp , false ) ;
141
+ removeGlobalListener ( window , 'touchend' , onThumbUp , false ) ;
142
+ }
136
143
}
137
144
} ;
138
145
@@ -149,9 +156,12 @@ export function useColorWheel(props: ColorWheelAriaProps, state: ColorWheelState
149
156
focusInput ( ) ;
150
157
state . setDragging ( true ) ;
151
158
152
- addGlobalListener ( window , 'mouseup' , onTrackUp , false ) ;
153
- addGlobalListener ( window , 'touchend' , onTrackUp , false ) ;
154
- addGlobalListener ( window , 'pointerup' , onTrackUp , false ) ;
159
+ if ( typeof PointerEvent !== 'undefined' ) {
160
+ addGlobalListener ( window , 'pointerup' , onTrackUp , false ) ;
161
+ } else {
162
+ addGlobalListener ( window , 'mouseup' , onTrackUp , false ) ;
163
+ addGlobalListener ( window , 'touchend' , onTrackUp , false ) ;
164
+ }
155
165
}
156
166
} ;
157
167
@@ -163,9 +173,13 @@ export function useColorWheel(props: ColorWheelAriaProps, state: ColorWheelState
163
173
state . setDragging ( false ) ;
164
174
focusInput ( ) ;
165
175
166
- removeGlobalListener ( window , 'mouseup' , onTrackUp , false ) ;
167
- removeGlobalListener ( window , 'touchend' , onTrackUp , false ) ;
168
- removeGlobalListener ( window , 'pointerup' , onTrackUp , false ) ;
176
+
177
+ if ( typeof PointerEvent !== 'undefined' ) {
178
+ removeGlobalListener ( window , 'pointerup' , onTrackUp , false ) ;
179
+ } else {
180
+ removeGlobalListener ( window , 'mouseup' , onTrackUp , false ) ;
181
+ removeGlobalListener ( window , 'touchend' , onTrackUp , false ) ;
182
+ }
169
183
}
170
184
} ;
171
185
@@ -185,21 +199,23 @@ export function useColorWheel(props: ColorWheelAriaProps, state: ColorWheelState
185
199
} ) ;
186
200
187
201
let trackInteractions = isDisabled ? { } : mergeProps ( {
188
- onMouseDown : ( e : React . MouseEvent ) => {
189
- if ( e . button !== 0 || e . altKey || e . ctrlKey || e . metaKey ) {
190
- return ;
191
- }
192
- onTrackDown ( e . currentTarget , undefined , e . clientX , e . clientY ) ;
193
- } ,
194
- onPointerDown : ( e : React . PointerEvent ) => {
195
- if ( e . pointerType === 'mouse' && ( e . button !== 0 || e . altKey || e . ctrlKey || e . metaKey ) ) {
196
- return ;
197
- }
198
- onTrackDown ( e . currentTarget , e . pointerId , e . clientX , e . clientY ) ;
199
- } ,
200
- onTouchStart : ( e : React . TouchEvent ) => {
201
- onTrackDown ( e . currentTarget , e . changedTouches [ 0 ] . identifier , e . changedTouches [ 0 ] . clientX , e . changedTouches [ 0 ] . clientY ) ;
202
- }
202
+ ...( typeof PointerEvent !== 'undefined' ? {
203
+ onPointerDown : ( e : React . PointerEvent ) => {
204
+ if ( e . pointerType === 'mouse' && ( e . button !== 0 || e . altKey || e . ctrlKey || e . metaKey ) ) {
205
+ return ;
206
+ }
207
+ onTrackDown ( e . currentTarget , e . pointerId , e . clientX , e . clientY ) ;
208
+ } } : {
209
+ onMouseDown : ( e : React . MouseEvent ) => {
210
+ if ( e . button !== 0 || e . altKey || e . ctrlKey || e . metaKey ) {
211
+ return ;
212
+ }
213
+ onTrackDown ( e . currentTarget , undefined , e . clientX , e . clientY ) ;
214
+ } ,
215
+ onTouchStart : ( e : React . TouchEvent ) => {
216
+ onTrackDown ( e . currentTarget , e . changedTouches [ 0 ] . identifier , e . changedTouches [ 0 ] . clientX , e . changedTouches [ 0 ] . clientY ) ;
217
+ }
218
+ } )
203
219
} , movePropsContainer ) ;
204
220
205
221
let thumbInteractions = isDisabled ? { } : mergeProps ( {
0 commit comments