@@ -158,7 +158,9 @@ export function animateValue<V = number>({
158
158
}
159
159
160
160
// Rebase on delay
161
- time = Math . max ( time - delay , 0 )
161
+ const timeWithDelay = time - delay
162
+ const isInDelayPhase = timeWithDelay < 0
163
+ time = Math . max ( timeWithDelay , 0 )
162
164
163
165
/**
164
166
* If this animation has finished, set the current time
@@ -229,15 +231,22 @@ export function animateValue<V = number>({
229
231
elapsed = p * resolvedDuration
230
232
}
231
233
232
- const state = frameGenerator . next ( elapsed )
234
+ /**
235
+ * If we're in negative time, set state as the initial keyframe.
236
+ * This prevents delay: x, duration: 0 animations from finishing
237
+ * instantly.
238
+ */
239
+ const state = isInDelayPhase
240
+ ? { done : false , value : keyframes [ 0 ] }
241
+ : frameGenerator . next ( elapsed )
233
242
234
243
if ( mapNumbersToKeyframes ) {
235
244
state . value = mapNumbersToKeyframes ( state . value )
236
245
}
237
246
238
247
let { done } = state
239
248
240
- if ( calculatedDuration !== null ) {
249
+ if ( ! isInDelayPhase && calculatedDuration !== null ) {
241
250
done = time >= totalDuration
242
251
}
243
252
@@ -323,6 +332,14 @@ export function animateValue<V = number>({
323
332
startTime = animationDriver . now ( ) - newTime / speed
324
333
}
325
334
} ,
335
+ get duration ( ) {
336
+ const duration =
337
+ generator . calculatedDuration === null
338
+ ? calculateDuration ( generator )
339
+ : generator . calculatedDuration
340
+
341
+ return millisecondsToSeconds ( duration )
342
+ } ,
326
343
get speed ( ) {
327
344
return speed
328
345
} ,
0 commit comments