9
9
LEFT ,
10
10
RIGHT ,
11
11
Setter ,
12
+ ConfigurationOptions ,
12
13
SwipeableCallbacks ,
13
14
SwipeableHandlers ,
14
15
SwipeableProps ,
@@ -34,7 +35,7 @@ export {
34
35
Vector2 ,
35
36
} ;
36
37
37
- const defaultProps = {
38
+ const defaultProps : ConfigurationOptions = {
38
39
delta : 10 ,
39
40
preventDefaultTouchmoveEvent : false ,
40
41
rotationAngle : 0 ,
@@ -253,7 +254,7 @@ function getHandlers(
253
254
// if new DOM el clean up old DOM and reset cleanUpTouch
254
255
if ( state . el && state . el !== el && state . cleanUpTouch ) {
255
256
state . cleanUpTouch ( ) ;
256
- addState . cleanUpTouch = undefined ;
257
+ addState . cleanUpTouch = void 0 ;
257
258
}
258
259
// only attach if we want to track touch
259
260
if ( props . trackTouch && el ) {
@@ -290,7 +291,7 @@ function updateTransientState(
290
291
// clean up touch handlers if no longer tracking touches
291
292
if ( ! props . trackTouch && state . cleanUpTouch ) {
292
293
state . cleanUpTouch ( ) ;
293
- addState . cleanUpTouch = undefined ;
294
+ addState . cleanUpTouch = void 0 ;
294
295
} else if ( props . trackTouch && ! state . cleanUpTouch ) {
295
296
// attach/re-attach touch handlers
296
297
if ( state . el ) {
@@ -309,7 +310,20 @@ export function useSwipeable(options: SwipeableProps): SwipeableHandlers {
309
310
const transientProps = React . useRef < SwipeablePropsWithDefaultOptions > ( {
310
311
...defaultProps ,
311
312
} ) ;
312
- transientProps . current = { ...defaultProps , ...options } ;
313
+ transientProps . current = {
314
+ ...defaultProps ,
315
+ ...options ,
316
+ // Force defaults for config properties
317
+ delta : options . delta === void 0 ? defaultProps . delta : options . delta ,
318
+ rotationAngle :
319
+ options . rotationAngle === void 0
320
+ ? defaultProps . rotationAngle
321
+ : options . rotationAngle ,
322
+ trackTouch :
323
+ options . trackTouch === void 0
324
+ ? defaultProps . trackTouch
325
+ : options . trackTouch ,
326
+ } ;
313
327
314
328
const [ handlers , attachTouch ] = React . useMemo (
315
329
( ) =>
0 commit comments