@@ -2,7 +2,12 @@ import { isObject } from '@vueuse/core'
2
2
import type { Ref , VNode } from 'vue'
3
3
import type { MotionVariants } from '../types'
4
4
5
- const directivePropsKeys = [ 'initial' , 'enter' , 'leave' , 'visible' , 'visible-once' , 'visibleOnce' , 'hovered' , 'tapped' , 'focused' , 'delay' ]
5
+ const transitionKeys = [ 'delay' , 'duration' ] as const
6
+ const directivePropsKeys = [ 'initial' , 'enter' , 'leave' , 'visible' , 'visible-once' , 'visibleOnce' , 'hovered' , 'tapped' , 'focused' , ...transitionKeys ] as const
7
+
8
+ function isTransitionKey ( val : any ) : val is 'delay' | 'duration' {
9
+ return transitionKeys . includes ( val )
10
+ }
6
11
7
12
export function resolveVariants < T extends string > ( node : VNode < any , HTMLElement | SVGElement , Record < string , any > > , variantsRef : Ref < MotionVariants < T > > ) {
8
13
// This is done to achieve compat with Vue 2 & 3
@@ -27,15 +32,16 @@ export function resolveVariants<T extends string>(node: VNode<any, HTMLElement |
27
32
for ( let key of directivePropsKeys ) {
28
33
if ( ! target || ! target [ key ] ) continue
29
34
30
- if ( key === 'delay' && typeof target [ key ] === 'number' ) {
31
- // Apply delay to existing variants where applicable
35
+ if ( isTransitionKey ( key ) && typeof target [ key ] === 'number' ) {
36
+ // Apply transition property to existing variants where applicable
32
37
for ( const variantKey of [ 'enter' , 'visible' , 'visibleOnce' ] as const ) {
33
38
const variantConfig = variantsRef . value [ variantKey ]
34
39
35
40
if ( variantConfig == null ) continue
36
41
37
42
variantConfig . transition ??= { }
38
- variantConfig . transition . delay = target [ key ]
43
+ // @ts -expect-error `duration` does not exist on `inertia` type transitions
44
+ variantConfig . transition [ key ] = target [ key ]
39
45
}
40
46
41
47
continue
0 commit comments