File tree 1 file changed +2
-26
lines changed
1 file changed +2
-26
lines changed Original file line number Diff line number Diff line change 1
- import { getCurrentInstance , onMounted , shallowReactive } from 'vue'
2
- import { MotionDirectiveInjection } from './plugin'
1
+ import { motionState } from './features/state'
3
2
4
- /**
5
- * A Composable giving access to current component instance `$motions` instances declared via `v-motion` from the template.
6
- */
7
3
export function useMotions ( ) {
8
- // Get the current component instance
9
- const app = getCurrentInstance ( )
10
-
11
- // Create a shallow reactive object, holding motions
12
- const motions = shallowReactive < MotionDirectiveInjection > ( { } )
13
-
14
- // On mounted, get all the $motions, and bind them to the shallow reactive object
15
- onMounted ( ( ) => {
16
- // Check if the current component instance has $motions injected
17
- if ( app ?. proxy ?. $motions ) {
18
- // Append the local shallowReactive object with all the $motions injected in the component instance
19
- Object . assign ( motions , app . proxy . $motions )
20
- } else {
21
- // If there's no v-motions in the component, this hook shouldn't be present in setup().
22
- console . warn (
23
- `Could not find any motion in this component, are you using v-motion anywhere?` ,
24
- )
25
- }
26
- } )
27
-
28
- return motions
4
+ return motionState
29
5
}
You can’t perform that action at this time.
0 commit comments