Skip to content

Commit de807fd

Browse files
authoredSep 15, 2022
fix: applying a new config to useGesture / Gesture shouldn't throw an error (#542)
1 parent 8f27425 commit de807fd

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed
 

‎.changeset/dirty-planets-protect.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@use-gesture/core': patch
3+
---
4+
5+
fix: applying a new config to useGesture / Gesture shouldn't throw an error.

‎packages/core/src/Controller.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export class Controller {
6666
* @param gestureKey
6767
*/
6868
applyConfig(config: UserGestureConfig, gestureKey?: GestureKey) {
69-
this.config = parse(config, gestureKey)
69+
this.config = parse(config, gestureKey, this.config)
7070
}
7171
/**
7272
* Cleans all side effects (listeners, timeouts). When the gesture is

‎packages/core/src/config/resolver.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,10 @@ export function resolveWith<T extends { [k: string]: any }, V extends { [k: stri
3434
return result
3535
}
3636

37-
export function parse(config: UserGestureConfig, gestureKey?: GestureKey): InternalConfig {
38-
const { target, eventOptions, window, enabled, transform, ...rest } = config as any
37+
export function parse(newConfig: UserGestureConfig, gestureKey?: GestureKey, _config: any = {}): InternalConfig {
38+
const { target, eventOptions, window, enabled, transform, ...rest } = newConfig as any
3939

40-
const _config: any = {
41-
shared: resolveWith({ target, eventOptions, window, enabled, transform }, sharedConfigResolver)
42-
}
40+
_config.shared = resolveWith({ target, eventOptions, window, enabled, transform }, sharedConfigResolver)
4341

4442
if (gestureKey) {
4543
const resolver = ConfigResolverMap.get(gestureKey)!

0 commit comments

Comments
 (0)
Please sign in to comment.