Skip to content

Commit

Permalink
fix: stop merging default pause/cancel in scheduleProps
Browse files Browse the repository at this point in the history
The `SpringValue#_update` method does it for us now.
  • Loading branch information
aleclarson committed Sep 26, 2020
1 parent 39b40f3 commit 55a1379
Showing 1 changed file with 2 additions and 19 deletions.
21 changes: 2 additions & 19 deletions packages/core/src/scheduleProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ export function scheduleProps<T extends AnimationTarget>(
let delay: number
let timeout: Timeout

let cancel = mergeDefaultProp(defaultProps, props, 'cancel')
cancel = matchProp(props.cancel ?? cancel, key)

let cancel = matchProp(props.cancel ?? defaultProps?.cancel, key)
if (cancel) {
onStart()
} else {
Expand All @@ -51,7 +49,7 @@ export function scheduleProps<T extends AnimationTarget>(
}
// The default `pause` takes precedence when true,
// which allows `SpringContext` to work as expected.
let pause = mergeDefaultProp(defaultProps, props, 'pause')
let pause = defaultProps?.pause
if (pause !== true) {
pause = state.paused || matchProp(pause, key)
}
Expand Down Expand Up @@ -101,18 +99,3 @@ export function scheduleProps<T extends AnimationTarget>(
}
})
}

/** Update and return the default prop. */
function mergeDefaultProp<T>(
defaultProps: DefaultProps<T> | undefined,
props: DefaultProps<T>,
key: keyof DefaultProps<T>
) {
let value: any
return (
defaultProps &&
(is.und((value = getDefaultProp(props, key)))
? defaultProps[key]
: (defaultProps[key] = value))
)
}

0 comments on commit 55a1379

Please sign in to comment.