* Stop the current animation, and cancel any delayed updates. * * Pass `true` to call `onRest` with `cancelled: true`.
(cancel?: boolean)
| 486 | * Pass `true` to call `onRest` with `cancelled: true`. |
| 487 | */ |
| 488 | stop(cancel?: boolean) { |
| 489 | const { to } = this.animation |
| 490 | |
| 491 | // The current value becomes the goal value — but only if a goal |
| 492 | // ever existed. Otherwise we'd be establishing one where none was |
| 493 | // set (matters for paused/uninitialised springs whose underlying |
| 494 | // value was seeded via `from` during `_prepareNode`). This becomes |
| 495 | // observable under React.StrictMode, whose simulated unmount fires |
| 496 | // the useSprings cleanup `ctrl.stop(true)` on springs that never |
| 497 | // got a chance to start. |
| 498 | if (!is.und(to)) { |
| 499 | this._focus(this.get()) |
| 500 | } |
| 501 | |
| 502 | stopAsync(this._state, cancel && this._lastCallId) |
| 503 | raf.batchedUpdates(() => this._stop(to, cancel)) |
| 504 | |
| 505 | return this |
| 506 | } |
| 507 | |
| 508 | /** Restart the animation. */ |
| 509 | reset() { |