MCPcopy
hub / github.com/chenglou/react-motion / shouldStopAnimation

Function shouldStopAnimation

src/shouldStopAnimation.js:6–31  ·  view source on GitHub ↗
(
  currentStyle: PlainStyle,
  style: Style,
  currentVelocity: Velocity,
)

Source from the content-addressed store, hash-verified

4// usage assumption: currentStyle values have already been rendered but it says
5// nothing of whether currentStyle is stale (see unreadPropStyle)
6export default function shouldStopAnimation(
7 currentStyle: PlainStyle,
8 style: Style,
9 currentVelocity: Velocity,
10): boolean {
11 for (let key in style) {
12 if (!Object.prototype.hasOwnProperty.call(style, key)) {
13 continue;
14 }
15
16 if (currentVelocity[key] !== 0) {
17 return false;
18 }
19
20 const styleValue = typeof style[key] === 'number'
21 ? style[key]
22 : style[key].val;
23 // stepper will have already taken care of rounding precision errors, so
24 // won't have such thing as 0.9999 !=== 1
25 if (currentStyle[key] !== styleValue) {
26 return false;
27 }
28 }
29
30 return true;
31}

Callers 4

MotionClass · 0.85
shouldStopAnimationAllFunction · 0.85
shouldStopAnimationAllFunction · 0.85
mergeAndSyncFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…