-
-
Notifications
You must be signed in to change notification settings - Fork 93
/
Copy pathinstance.ts
99 lines (90 loc) · 2.49 KB
/
instance.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import type { VueInstance } from '@vueuse/core'
import type { MaybeRef, Ref, UnwrapRef } from 'vue'
import type { MotionProperties, MotionVariants, Variant } from './variants'
export type PermissiveTarget = VueInstance | MotionTarget
export type MotionTarget = HTMLElement | SVGElement | null | undefined
export interface MotionInstance<T extends string, V extends MotionVariants<T>> extends MotionControls<T, V> {
target: MaybeRef<PermissiveTarget>
variants: MaybeRef<V>
variant: Ref<keyof V>
state: Ref<Variant | undefined>
motionProperties: UnwrapRef<MotionProperties>
}
export interface UseMotionOptions {
syncVariants?: boolean
lifeCycleHooks?: boolean
visibilityHooks?: boolean
eventListeners?: boolean
}
export interface MotionControls<T extends string, V extends MotionVariants<T>> {
/**
* Apply a variant declaration and execute the resolved transitions.
*
* @param variant
* @returns Promise<void[]>
*/
apply: (variant: Variant | keyof V) => Promise<void[]> | undefined
/**
* Apply a variant declaration without transitions.
*
* @param variant
*/
set: (variant: Variant | keyof V) => void
/**
* Stop all the ongoing transitions for the current element.
*/
stop: (keys?: string | string[]) => void
/**
* Helper to be passed to <transition> leave event.
*
* @param done
*/
leave: (done: () => void) => void
/**
* Computed reference reactive to the animation state of motion controls.
*/
isAnimating: any
}
export interface SpringControls {
/**
* Apply new values with transitions.
*
* @param variant
*/
set: (properties: MotionProperties) => void
/**
* Stop all transitions.
*
* @param variant
*/
stop: (key?: string | string[]) => void
/**
* Object containing all the current values of the spring.
*
* @param
*/
values: MotionProperties
}
export type MotionInstanceBindings<T extends string, V extends MotionVariants<T>> = Record<string, MotionInstance<T, V>>
declare module 'vue' {
export interface ComponentCustomProperties {
$motions?: MotionInstanceBindings<any, any>
}
}
declare module '@vue/runtime-dom' {
interface HTMLAttributes {
variants?: MotionVariants<any>
// Initial variant
initial?: Variant
// Lifecycle hooks variants
enter?: Variant
leave?: Variant
// Intersection observer variants
visible?: Variant
visibleOnce?: Variant
// Event listeners variants
hovered?: Variant
tapped?: Variant
focused?: Variant
}
}