MCPcopy
hub / github.com/pmndrs/react-spring / stop

Method stop

packages/core/src/SpringValue.ts:488–506  ·  view source on GitHub ↗

* Stop the current animation, and cancel any delayed updates. * * Pass `true` to call `onRest` with `cancelled: true`.

(cancel?: boolean)

Source from the content-addressed store, hash-verified

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() {

Callers 2

_mergeMethod · 0.95
describeEventsFunction · 0.95

Calls 4

_focusMethod · 0.95
_stopMethod · 0.95
stopAsyncFunction · 0.90
getMethod · 0.65

Tested by 1

describeEventsFunction · 0.76