Skip to content

Commit f1b14af

Browse files
authored
Merge pull request #167 from motiondivision/chore/motion-utils
chore: refactor imports from motion. reuse more utils
2 parents 4c85dba + 9a87736 commit f1b14af

File tree

15 files changed

+125
-99
lines changed

15 files changed

+125
-99
lines changed

packages/motion/src/components/motion/use-motion-state.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import { checkMotionIsHidden } from '@/components/motion/utils'
77
import { injectAnimatePresence } from '@/components/presence'
88
import { MotionState } from '@/state'
99
import { convertSvgStyleToAttributes, createStyles } from '@/state/style'
10-
import { isMotionValue } from '@/utils'
1110
import type { DOMKeyframesDefinition } from 'framer-motion'
11+
import { isMotionValue } from 'framer-motion/dom'
1212
import { invariant, warning } from 'hey-listen'
1313
import { getCurrentInstance, onBeforeMount, onBeforeUnmount, onBeforeUpdate, onMounted, onUnmounted, onUpdated, ref, useAttrs } from 'vue'
1414

packages/motion/src/components/reorder/utils.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import type { ItemData } from '@/components/reorder/types'
2-
import { isMotionValue } from '@/utils'
3-
import { mixNumber } from '@/utils/mix/number'
4-
import { motionValue } from 'framer-motion/dom'
2+
import { isMotionValue, mixNumber, motionValue } from 'framer-motion/dom'
53

64
export function compareMin<V>(a: ItemData<V>, b: ItemData<V>) {
75
return a.layout.min - b.layout.min

packages/motion/src/features/gestures/drag/VisualElementDragControls.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,12 @@ import { createBox } from '@/projection/geometry/models'
1111
import { eachAxis } from '@/projection/utils/each-axis'
1212
import type { Options } from '@/types'
1313
import { getContextWindow } from '@/utils'
14-
import { percent } from '@/value/types/numbers/units'
1514
import { addValueToWillChange } from '@/value/use-will-change/add-will-change'
1615
import type { Axis, BoundingBox, Point, Transition, VisualElement } from 'framer-motion'
17-
import { frame } from 'framer-motion/dom'
16+
import { frame, mixNumber, percent } from 'framer-motion/dom'
1817
import { measurePageBox } from '@/projection/utils/measure'
1918
import { convertBoundingBoxToBox, convertBoxToBoundingBox } from '@/projection/conversion'
2019
import { animateMotionValue } from 'framer-motion/dist/es/animation/interfaces/motion-value.mjs'
21-
import { mixNumber } from '@/utils/mix/number'
2220
import type { LayoutUpdateData } from '@/projection/node/types'
2321
import { invariant } from 'hey-listen'
2422
import { isPresent } from '@/state/utils/is-present'

packages/motion/src/features/gestures/drag/utils/constraints.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import type { ResolvedConstraints } from '@/features/gestures/drag/types'
22
import { calcLength } from '@/projection/geometry/delta-calc'
3-
import { clamp } from '@/utils/clamp'
4-
import { mixNumber } from '@/utils/mix/number'
5-
import { progress as calcProgress } from '@/utils/progress'
3+
import { progress as calcProgress, clamp, mixNumber } from 'framer-motion/dom'
64
import type { Axis, BoundingBox, Box, DragElastic } from 'framer-motion'
75

86
/**

packages/motion/src/state/style.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import type { DOMKeyframesDefinition, ResolvedValues } from 'framer-motion'
22
import { isCssVar, isNumber } from './utils'
33
import { buildTransformTemplate, isTransform, transformAlias, transformDefinitions } from './transform'
4-
import { isMotionValue } from '@/utils'
4+
import { isMotionValue, px } from 'framer-motion/dom'
55
import type { MotionStyle } from '@/types'
6-
import { px } from '@/value/types/numbers/units'
76

87
type MotionStyleKey = Exclude<
98
keyof CSSStyleDeclaration,

packages/motion/src/utils/clamp.ts

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

packages/motion/src/utils/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
export * from './createContext'
2-
export * from './motion-value'
32
export * from './use-in-view'
43
export * from './use-animation-frame'
54
export * from './get-context-window'

packages/motion/src/utils/mix/number.ts

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

packages/motion/src/utils/motion-value.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

packages/motion/src/utils/progress.ts

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

0 commit comments

Comments
 (0)