Skip to content

Commit 8ea3e4c

Browse files
committed
Latest
1 parent cb08012 commit 8ea3e4c

File tree

17 files changed

+50
-161
lines changed

17 files changed

+50
-161
lines changed

packages/framer-motion/src/context/PresenceContext.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,9 @@
11
"use client"
22

33
import { createContext } from "react"
4-
import { VariantLabels } from "../motion/types"
4+
import type { PresenceContextProps } from "motion-dom"
55

6-
/**
7-
* @public
8-
*/
9-
export interface PresenceContextProps {
10-
id: string
11-
isPresent: boolean
12-
register: (id: string | number) => () => void
13-
onExitComplete?: (id: string | number) => void
14-
initial?: false | VariantLabels
15-
custom?: any
16-
}
6+
export type { PresenceContextProps }
177

188
/**
199
* @public

packages/framer-motion/src/motion/features/animation/index.ts

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,9 @@ import {
22
createAnimationState,
33
Feature,
44
isAnimationControls,
5-
animateVisualElement,
65
type VisualElement,
76
} from "motion-dom"
87

9-
/**
10-
* Creates the animate function that will be used by the animation state
11-
* to perform actual animations using framer-motion's animation system.
12-
*/
13-
function makeAnimateFunction(visualElement: VisualElement) {
14-
return (animations: Array<{ animation: any; options?: any }>) => {
15-
return Promise.all(
16-
animations.map(({ animation, options }) =>
17-
animateVisualElement(visualElement, animation, options)
18-
)
19-
)
20-
}
21-
}
22-
238
export class AnimationFeature extends Feature<unknown> {
249
unmountControls?: () => void
2510

@@ -30,7 +15,7 @@ export class AnimationFeature extends Feature<unknown> {
3015
*/
3116
constructor(node: VisualElement) {
3217
super(node)
33-
node.animationState ||= createAnimationState(node, makeAnimateFunction)
18+
node.animationState ||= createAnimationState(node)
3419
}
3520

3621
updateAnimationControlsSubscription() {

packages/framer-motion/src/motion/utils/is-forced-motion-value.ts

Lines changed: 0 additions & 14 deletions
This file was deleted.

packages/framer-motion/src/render/html/use-props.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
"use client"
22

3-
import { AnyResolvedKeyframe, buildHTMLStyles, isMotionValue, MotionValue } from "motion-dom"
3+
import { AnyResolvedKeyframe, buildHTMLStyles, isForcedMotionValue, isMotionValue, MotionValue } from "motion-dom"
44
import { HTMLProps, useMemo } from "react"
55
import { MotionProps } from "../../motion/types"
6-
import { isForcedMotionValue } from "../../motion/utils/is-forced-motion-value"
76
import { ResolvedValues } from "../types"
87
import { createHtmlRenderState } from "./utils/create-render-state"
98

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,7 @@
1-
import { isMotionValue, type VisualElement } from "motion-dom"
2-
import { MotionProps, MotionStyle } from "../../../motion/types"
3-
import { isForcedMotionValue } from "../../../motion/utils/is-forced-motion-value"
1+
import {
2+
scrapeHTMLMotionValuesFromProps,
3+
type ScrapeMotionValuesFromProps,
4+
} from "motion-dom"
45

5-
export function scrapeMotionValuesFromProps(
6-
props: MotionProps,
7-
prevProps: MotionProps,
8-
visualElement?: VisualElement
9-
) {
10-
const { style } = props
11-
const newValues: { [key: string]: any } = {}
12-
13-
for (const key in style) {
14-
if (
15-
isMotionValue(style[key as keyof MotionStyle]) ||
16-
(prevProps.style &&
17-
isMotionValue(prevProps.style[key as keyof MotionStyle])) ||
18-
isForcedMotionValue(key, props) ||
19-
visualElement?.getValue(key)?.liveStyle !== undefined
20-
) {
21-
newValues[key] = style[key as keyof MotionStyle]
22-
}
23-
}
24-
25-
return newValues
26-
}
6+
export const scrapeMotionValuesFromProps =
7+
scrapeHTMLMotionValuesFromProps as ScrapeMotionValuesFromProps
Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,7 @@
1-
import { isMotionValue, transformPropOrder, type VisualElement } from "motion-dom"
2-
import { MotionProps } from "../../../motion/types"
3-
import { scrapeMotionValuesFromProps as scrapeHTMLMotionValuesFromProps } from "../../html/utils/scrape-motion-values"
1+
import {
2+
scrapeSVGMotionValuesFromProps,
3+
type ScrapeMotionValuesFromProps,
4+
} from "motion-dom"
45

5-
export function scrapeMotionValuesFromProps(
6-
props: MotionProps,
7-
prevProps: MotionProps,
8-
visualElement?: VisualElement
9-
) {
10-
const newValues = scrapeHTMLMotionValuesFromProps(
11-
props,
12-
prevProps,
13-
visualElement
14-
)
15-
16-
for (const key in props) {
17-
if (
18-
isMotionValue(props[key as keyof typeof props]) ||
19-
isMotionValue(prevProps[key as keyof typeof prevProps])
20-
) {
21-
const targetKey =
22-
transformPropOrder.indexOf(key) !== -1
23-
? "attr" + key.charAt(0).toUpperCase() + key.substring(1)
24-
: key
25-
26-
newValues[targetKey] = props[key as keyof typeof props]
27-
}
28-
}
29-
30-
return newValues
31-
}
6+
export const scrapeMotionValuesFromProps =
7+
scrapeSVGMotionValuesFromProps as ScrapeMotionValuesFromProps

packages/framer-motion/src/render/types.ts

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,19 @@ import {
22
AnyResolvedKeyframe,
33
MotionValue,
44
ResolvedValues,
5-
type AnimationDefinition,
65
type VisualElement,
6+
type VisualElementEventCallbacks,
7+
type LayoutLifecycles,
8+
type UseRenderState,
79
} from "motion-dom"
8-
import type { Axis, Box } from "motion-utils"
910
import { ReducedMotionConfig } from "../context/MotionConfigContext"
1011
import type { PresenceContextProps } from "../context/PresenceContext"
1112
import { MotionProps } from "../motion/types"
1213
import { VisualState } from "../motion/utils/use-visual-state"
1314
import { DOMMotionComponents } from "./dom/types"
1415

16+
export type { VisualElementEventCallbacks, LayoutLifecycles, UseRenderState }
17+
1518
export type ScrapeMotionValuesFromProps = (
1619
props: MotionProps,
1720
prevProps: MotionProps,
@@ -20,8 +23,6 @@ export type ScrapeMotionValuesFromProps = (
2023
[key: string]: MotionValue | AnyResolvedKeyframe
2124
}
2225

23-
export type UseRenderState<RenderState = any> = () => RenderState
24-
2526
export interface VisualElementOptions<Instance, RenderState = any> {
2627
visualState: VisualState<Instance, RenderState>
2728
parent?: VisualElement<unknown>
@@ -40,35 +41,6 @@ export interface VisualElementOptions<Instance, RenderState = any> {
4041
// Re-export ResolvedValues from motion-dom for backward compatibility
4142
export type { ResolvedValues }
4243

43-
export interface VisualElementEventCallbacks {
44-
BeforeLayoutMeasure: () => void
45-
LayoutMeasure: (layout: Box, prevLayout?: Box) => void
46-
LayoutUpdate: (layout: Axis, prevLayout: Axis) => void
47-
Update: (latest: ResolvedValues) => void
48-
AnimationStart: (definition: AnimationDefinition) => void
49-
AnimationComplete: (definition: AnimationDefinition) => void
50-
LayoutAnimationStart: () => void
51-
LayoutAnimationComplete: () => void
52-
SetAxisTarget: () => void
53-
Unmount: () => void
54-
}
55-
56-
export interface LayoutLifecycles {
57-
onBeforeLayoutMeasure?(box: Box): void
58-
59-
onLayoutMeasure?(box: Box, prevBox: Box): void
60-
61-
/**
62-
* @internal
63-
*/
64-
onLayoutAnimationStart?(): void
65-
66-
/**
67-
* @internal
68-
*/
69-
onLayoutAnimationComplete?(): void
70-
}
71-
7244
export type CreateVisualElement<
7345
Props = {},
7446
TagName extends keyof DOMMotionComponents | string = "div"

packages/motion-dom/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,11 +220,13 @@ export { mixValues } from "./projection/animation/mix-values"
220220
export { buildHTMLStyles } from "./render/html/utils/build-styles"
221221
export { buildTransform } from "./render/html/utils/build-transform"
222222
export { renderHTML } from "./render/html/utils/render"
223+
export { scrapeMotionValuesFromProps as scrapeHTMLMotionValuesFromProps } from "./render/html/utils/scrape-motion-values"
223224
export { buildSVGAttrs } from "./render/svg/utils/build-attrs"
224225
export { renderSVG } from "./render/svg/utils/render"
225226
export { buildSVGPath } from "./render/svg/utils/path"
226227
export { camelCaseAttributes } from "./render/svg/utils/camel-case-attrs"
227228
export { isSVGTag } from "./render/svg/utils/is-svg-tag"
229+
export { scrapeMotionValuesFromProps as scrapeSVGMotionValuesFromProps } from "./render/svg/utils/scrape-motion-values"
228230
export { camelToDash } from "./render/dom/utils/camel-to-dash"
229231

230232
/**

packages/framer-motion/src/projection/animation/__tests__/mix-values.test.ts renamed to packages/motion-dom/src/projection/animation/__tests__/mix-values.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { mixValues } from "motion-dom"
1+
import { mixValues } from "../mix-values"
22

33
describe("mixValues", () => {
44
test("mixes borderRadius numbers", () => {

packages/framer-motion/src/projection/geometry/__tests__/conversion.test.ts renamed to packages/motion-dom/src/projection/geometry/__tests__/conversion.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { convertBoundingBoxToBox } from "motion-dom"
1+
import { convertBoundingBoxToBox } from "../conversion"
22

33
describe("convertBoundingBoxToBox", () => {
44
it("Correctly converts a bounding box into a box", () => {

0 commit comments

Comments
 (0)