Skip to content

Commit

Permalink
Capping pregenerated keyframes
Browse files Browse the repository at this point in the history
  • Loading branch information
mattgperry committed Feb 24, 2023
1 parent b953fdb commit 6e3dd89
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ const acceleratedValues = new Set<string>([
*/
const sampleDelta = 10 //ms

const requiresPregeneratedKeyframes = (
valueName: string,
options: AnimationOptions
) =>
options.type === "spring" ||
valueName === "backgroundColor" ||
!isWaapiSupportedEasing(options.ease)

export function createAcceleratedAnimation(
value: MotionValue,
valueName: string,
Expand All @@ -46,11 +54,7 @@ export function createAcceleratedAnimation(
/**
* If this animation needs pre-generated keyframes then generate.
*/
if (
options.type === "spring" ||
valueName === "backgroundColor" ||
!isWaapiSupportedEasing(options.ease)
) {
if (requiresPregeneratedKeyframes(valueName, options)) {
const sampleAnimation = animateValue({
...options,
repeat: 0,
Expand Down

0 comments on commit 6e3dd89

Please sign in to comment.