Skip to content

Commit

Permalink
Add warning when animating more than 2 keyframes in a timeline with a…
Browse files Browse the repository at this point in the history
… spring (#3063)

* Latest

* Fixing normal warning

* Removing new warning

* Reverting example
  • Loading branch information
mattgperry authored Feb 12, 2025
1 parent fb01f43 commit ec9121e
Showing 1 changed file with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,17 +165,20 @@ export class MainThreadAnimation<
let mapPercentToKeyframes: ((v: number) => T) | undefined
let mirroredGenerator: KeyframeGenerator<T> | undefined

if (
process.env.NODE_ENV !== "production" &&
generatorFactory !== keyframesGeneratorFactory
) {
invariant(
keyframes.length <= 2,
`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${keyframes}`
)
}

if (
generatorFactory !== keyframesGeneratorFactory &&
typeof keyframes[0] !== "number"
) {
if (process.env.NODE_ENV !== "production") {
invariant(
keyframes.length === 2,
`Only two keyframes currently supported with spring and inertia animations. Trying to animate ${keyframes}`
)
}

mapPercentToKeyframes = pipe(
percentToProgress,
mix(keyframes[0], keyframes[1])
Expand Down

0 comments on commit ec9121e

Please sign in to comment.