mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Animated: Rename __debouncedOnEnd to __notifyAnimationEnd (#46718)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/46718 Simple rename of a protected method that should not be called by anyone outside of the `Animation` class and its subclasses, just to make it more intuitive. Changelog: [Internal] Reviewed By: javache Differential Revision: D63572363 fbshipit-source-id: cf68f63a9b361767b9dbfcd73124bcdae7a1806e
This commit is contained in:
1 parent
b519d49106
commit
11bf3a32e1
5 files changed
+21
-16
No files matched your search
@@ -88,13 +88,6 @@ export default class Animation {
|
||||
throw new Error('This animation type cannot be offloaded to native');
|
||||
}
|
||||
|
||||
// Helper function for subclasses to make sure onEnd is only called once.
|
||||
__debouncedOnEnd(result: EndResult): void {
|
||||
const onEnd = this.#onEnd;
|
||||
this.#onEnd = null;
|
||||
onEnd && onEnd(result);
|
||||
}
|
||||
|
||||
__findAnimatedPropsNodes(node: AnimatedNode): Array<AnimatedProps> {
|
||||
const result = [];
|
||||
|
||||
@@ -129,7 +122,7 @@ export default class Animation {
|
||||
animatedValue.__getNativeTag(),
|
||||
config,
|
||||
result => {
|
||||
this.__debouncedOnEnd(result);
|
||||
this.__notifyAnimationEnd(result);
|
||||
|
||||
// When using natively driven animations, once the animation completes,
|
||||
// we need to ensure that the JS side nodes are synced with the updated
|
||||
@@ -163,4 +156,16 @@ export default class Animation {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Notify the completion callback that the animation has ended. The completion
|
||||
* callback will never be called more than once.
|
||||
*/
|
||||
__notifyAnimationEnd(result: EndResult): void {
|
||||
const callback = this.#onEnd;
|
||||
if (callback != null) {
|
||||
this.#onEnd = null;
|
||||
callback(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -100,7 +100,7 @@ export default class DecayAnimation extends Animation {
|
||||
this._onUpdate(value);
|
||||
|
||||
if (Math.abs(this._lastValue - value) < 0.1) {
|
||||
this.__debouncedOnEnd({finished: true});
|
||||
this.__notifyAnimationEnd({finished: true});
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -116,6 +116,6 @@ export default class DecayAnimation extends Animation {
|
||||
if (this._animationFrame != null) {
|
||||
global.cancelAnimationFrame(this._animationFrame);
|
||||
}
|
||||
this.__debouncedOnEnd({finished: false});
|
||||
this.__notifyAnimationEnd({finished: false});
|
||||
}
|
||||
}
|
||||
@@ -354,7 +354,7 @@ export default class SpringAnimation extends Animation {
|
||||
this._onUpdate(this._toValue);
|
||||
}
|
||||
|
||||
this.__debouncedOnEnd({finished: true});
|
||||
this.__notifyAnimationEnd({finished: true});
|
||||
return;
|
||||
}
|
||||
// $FlowFixMe[method-unbinding] added when improving typing for this parameters
|
||||
@@ -367,6 +367,6 @@ export default class SpringAnimation extends Animation {
|
||||
if (this._animationFrame != null) {
|
||||
global.cancelAnimationFrame(this._animationFrame);
|
||||
}
|
||||
this.__debouncedOnEnd({finished: false});
|
||||
this.__notifyAnimationEnd({finished: false});
|
||||
}
|
||||
}
|
||||
@@ -124,7 +124,7 @@ export default class TimingAnimation extends Animation {
|
||||
// not cause intermixed JS and native animations.
|
||||
if (this._duration === 0) {
|
||||
this._onUpdate(this._toValue);
|
||||
this.__debouncedOnEnd({finished: true});
|
||||
this.__notifyAnimationEnd({finished: true});
|
||||
} else {
|
||||
this._animationFrame = requestAnimationFrame(() => this.onUpdate());
|
||||
}
|
||||
@@ -147,7 +147,7 @@ export default class TimingAnimation extends Animation {
|
||||
this._fromValue + this._easing(1) * (this._toValue - this._fromValue),
|
||||
);
|
||||
}
|
||||
this.__debouncedOnEnd({finished: true});
|
||||
this.__notifyAnimationEnd({finished: true});
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -168,6 +168,6 @@ export default class TimingAnimation extends Animation {
|
||||
if (this._animationFrame != null) {
|
||||
global.cancelAnimationFrame(this._animationFrame);
|
||||
}
|
||||
this.__debouncedOnEnd({finished: false});
|
||||
this.__notifyAnimationEnd({finished: false});
|
||||
}
|
||||
}
|
||||
@@ -443,9 +443,9 @@ declare export default class Animation {
|
||||
platformConfig: ?PlatformConfig,
|
||||
...
|
||||
}>;
|
||||
__debouncedOnEnd(result: EndResult): void;
|
||||
__findAnimatedPropsNodes(node: AnimatedNode): Array<AnimatedProps>;
|
||||
__startAnimationIfNative(animatedValue: AnimatedValue): boolean;
|
||||
__notifyAnimationEnd(result: EndResult): void;
|
||||
}
|
||||
"
|
||||
`;
|
||||
|
||||
Reference in new issue
Block a user