@@ -18,19 +18,22 @@ export function fly(node, {
18
18
duration = 400 ,
19
19
easing = cubicOut ,
20
20
x = 0 ,
21
- y = 0
21
+ y = 0 ,
22
+ opacity = 0
22
23
} ) {
23
24
const style = getComputedStyle ( node ) ;
24
- const opacity = + style . opacity ;
25
+ const target_opacity = + style . opacity ;
25
26
const transform = style . transform === 'none' ? '' : style . transform ;
26
27
28
+ const od = target_opacity - opacity ;
29
+
27
30
return {
28
31
delay,
29
32
duration,
30
33
easing,
31
34
css : t => `
32
35
transform: ${ transform } translate(${ ( 1 - t ) * x } px, ${ ( 1 - t ) * y } px);
33
- opacity: ${ t * opacity } `
36
+ opacity: ${ 1 - ( od * u ) } `
34
37
} ;
35
38
}
36
39
@@ -73,13 +76,12 @@ export function scale(node, {
73
76
start = 0 ,
74
77
opacity = 0
75
78
} ) {
76
- const sd = 1 - start ;
77
- const od = 1 - opacity ;
79
+ const style = getComputedStyle ( node ) ;
80
+ const target_opacity = + style . opacity ;
81
+ const transform = style . transform === 'none' ? '' : style . transform ;
78
82
79
- const transform = (
80
- node . style . transform ||
81
- getComputedStyle ( node ) . transform
82
- ) . replace ( 'none' , '' ) ;
83
+ const sd = 1 - start ;
84
+ const od = target_opacity - opacity ;
83
85
84
86
return {
85
87
delay,
@@ -94,11 +96,22 @@ export function scale(node, {
94
96
95
97
export function draw ( node , {
96
98
delay = 0 ,
97
- duration = 800 ,
99
+ speed,
100
+ duration,
98
101
easing = cubicInOut
99
102
} ) {
100
103
const len = node . getTotalLength ( ) ;
101
104
105
+ if ( duration === undefined ) {
106
+ if ( speed === undefined ) {
107
+ duration = 800 ;
108
+ } else {
109
+ duration = len / speed ;
110
+ }
111
+ } else if ( typeof duration === 'function' ) {
112
+ duration = duration ( len ) ;
113
+ }
114
+
102
115
return {
103
116
delay,
104
117
duration,
0 commit comments