Skip to content

Commit e0ead83

Browse files
committed
Fixing stop sync
1 parent 91c9ff9 commit e0ead83

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

packages/motion-dom/src/animation/JSAnimation.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
pipe,
66
secondsToMilliseconds,
77
} from "motion-utils"
8+
import { frame } from "../frameloop/frame"
89
import { time } from "../frameloop/sync-time"
910
import { activeAnimations } from "../stats/animation-count"
1011
import { mix } from "../utils/mix"
@@ -433,16 +434,13 @@ export class JSAnimation<T extends number | string>
433434
* animation.stop is returned as a reference from a useEffect.
434435
*/
435436
stop = () => {
436-
const { motionValue } = this.options
437-
if (motionValue && motionValue.updatedAt !== time.now()) {
438-
this.tick(time.now())
439-
}
440-
441-
this.isStopped = true
442-
if (this.state === "idle") return
443-
this.teardown()
444-
const { onStop } = this.options
445-
onStop && onStop()
437+
frame.preRender(() => {
438+
this.isStopped = true
439+
if (this.state === "idle") return
440+
this.teardown()
441+
const { onStop } = this.options
442+
onStop && onStop()
443+
})
446444
}
447445

448446
complete() {

0 commit comments

Comments
 (0)