diff --git a/dev/optimized-appear/persist-optimised-animation.html b/dev/optimized-appear/persist-optimised-animation.html new file mode 100644 index 0000000000..b9a0dbed0d --- /dev/null +++ b/dev/optimized-appear/persist-optimised-animation.html @@ -0,0 +1,109 @@ + +
+ + + + + + + + + + + + + diff --git a/packages/framer-motion/cypress/fixtures/appear-tests.json b/packages/framer-motion/cypress/fixtures/appear-tests.json index bf09b2a525..dcadccf8ac 100644 --- a/packages/framer-motion/cypress/fixtures/appear-tests.json +++ b/packages/framer-motion/cypress/fixtures/appear-tests.json @@ -1 +1 @@ -["defer-handoff.html","interrupt-delay-after.html","interrupt-delay-before-accelerated.html","interrupt-delay-before.html","interrupt-spring.html","interrupt-tween-opacity-waapi.html","interrupt-tween-opacity.html","interrupt-tween-transforms.html","interrupt-tween-x.html","persist.html","portal.html","resync-delay.html","resync.html","start-after-hydration.html"] \ No newline at end of file +["defer-handoff.html","interrupt-delay-after.html","interrupt-delay-before-accelerated.html","interrupt-delay-before.html","interrupt-spring.html","interrupt-tween-opacity-waapi.html","interrupt-tween-opacity.html","interrupt-tween-transforms.html","interrupt-tween-x.html","persist-optimised-animation.html","persist.html","portal.html","resync-delay.html","resync.html","start-after-hydration.html"] \ No newline at end of file diff --git a/packages/framer-motion/src/animation/interfaces/visual-element-target.ts b/packages/framer-motion/src/animation/interfaces/visual-element-target.ts index c2c0eeec11..3a1d803c41 100644 --- a/packages/framer-motion/src/animation/interfaces/visual-element-target.ts +++ b/packages/framer-motion/src/animation/interfaces/visual-element-target.ts @@ -10,6 +10,7 @@ import { setTarget } from "../../render/utils/setters" import { AnimationPlaybackControls } from "../types" import { getValueTransition } from "../utils/transitions" import { MotionValue } from "../../value" +import { frame } from "../../frameloop" /** * Decide whether we should block this animation. Previously, we achieved this @@ -90,7 +91,12 @@ export function animateTarget( visualElement.getProps()[optimizedAppearDataAttribute] if (appearId) { - const elapsed = window.HandoffAppearAnimations(appearId, key) + const elapsed = window.HandoffAppearAnimations( + appearId, + key, + value, + frame + ) if (elapsed !== null) { valueTransition.elapsed = elapsed diff --git a/packages/framer-motion/src/animation/optimized-appear/handoff.ts b/packages/framer-motion/src/animation/optimized-appear/handoff.ts index 22e82c5b09..ad6315237e 100644 --- a/packages/framer-motion/src/animation/optimized-appear/handoff.ts +++ b/packages/framer-motion/src/animation/optimized-appear/handoff.ts @@ -1,3 +1,5 @@ +import type { Batcher } from "../../frameloop/types" +import type { MotionValue } from "../../value" import { transformProps } from "../../render/html/utils/transform" import { appearAnimationStore } from "./store" import { appearStoreId } from "./store-id" @@ -6,7 +8,15 @@ let handoffFrameTime: number export function handoffOptimizedAppearAnimation( elementId: string, - valueName: string + valueName: string, + /** + * Legacy arguments. This function is inlined as part of SSG so it can be there's + * a version mismatch between the main included Motion and the inlined script. + * + * Remove in early 2024. + */ + _value: MotionValue, + _frame: Batcher ): number | null { const optimisedValueName = transformProps.has(valueName) ? "transform" diff --git a/packages/framer-motion/src/animation/optimized-appear/types.ts b/packages/framer-motion/src/animation/optimized-appear/types.ts index e7e943c81f..4d8e5d45f7 100644 --- a/packages/framer-motion/src/animation/optimized-appear/types.ts +++ b/packages/framer-motion/src/animation/optimized-appear/types.ts @@ -1,6 +1,17 @@ +import type { Batcher } from "../../frameloop/types" +import type { MotionValue } from "../../value" + export type HandoffFunction = ( storeId: string, - valueName: string + valueName: string, + /** + * Legacy arguments. This function is inlined as part of SSG so it can be there's + * a version mismatch between the main included Motion and the inlined script. + * + * Remove in early 2024. + */ + _value: MotionValue, + _frame: Batcher ) => null | number /**