File tree Expand file tree Collapse file tree 3 files changed +15
-9
lines changed
packages/framer-motion/src Expand file tree Collapse file tree 3 files changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -195,9 +195,21 @@ export function animateValue<V = number>({
195
195
* animate() can't yet be sampled for time, instead it
196
196
* consumes time. So to sample it we have to run a low
197
197
* temporal-resolution version.
198
+ *
199
+ * isControlled should be set to true if sample is being run within
200
+ * a loop. This indicates that we're not arbitrarily sampling
201
+ * the animation but running it one step after another. Therefore
202
+ * we don't need to run a low-res version here. This is a stop-gap
203
+ * until a rewrite can sample for time.
198
204
*/
199
- sample : ( t : number ) => {
205
+ sample : ( t : number , isControlled : boolean = false ) => {
200
206
elapsed = initialElapsed
207
+
208
+ if ( isControlled ) {
209
+ update ( t )
210
+ return state
211
+ }
212
+
201
213
const sampleResolution =
202
214
duration && typeof duration === "number"
203
215
? Math . max ( duration * 0.5 , 50 )
Original file line number Diff line number Diff line change @@ -69,7 +69,7 @@ export function createAcceleratedAnimation(
69
69
*/
70
70
let t = 0
71
71
while ( ! state . done && t < 20000 ) {
72
- state = sampleAnimation . sample ( t )
72
+ state = sampleAnimation . sample ( t , true )
73
73
pregeneratedKeyframes . push ( state . value )
74
74
t += sampleDelta
75
75
}
Original file line number Diff line number Diff line change @@ -17,13 +17,7 @@ export interface Step {
17
17
process : ( frame : FrameData ) => void
18
18
}
19
19
20
- export type StepId =
21
- | "read"
22
- | "update"
23
- | "postUpdate"
24
- | "preRender"
25
- | "render"
26
- | "postRender"
20
+ export type StepId = "read" | "update" | "preRender" | "render" | "postRender"
27
21
28
22
export type Sync = {
29
23
[ key in StepId ] : Schedule
You can’t perform that action at this time.
0 commit comments