Added AnimatedValueXY.removeAllListeners
Summary: > Explain the **motivation** for making this change. What existing problem does the pull request solve? `AnimatedValueX` has `removeAllListeners()` which is a convenient way to do cleanup when components unmount, but `AnimatedValueXY` was missing a similar method which doesn't really make sense. This change makes the two classes more similar, less confusing and more convenient. Closes https://github.com/facebook/react-native/pull/11783 Differential Revision: D4397188 fbshipit-source-id: d10a0c9c7e0a83af015ec04f6facf965d95ea984
This commit is contained in:
parent
237ee2ddf6
commit
6d2ae35bca
|
@ -1030,6 +1030,12 @@ class AnimatedValueXY extends AnimatedWithChildren {
|
||||||
delete this._listeners[id];
|
delete this._listeners[id];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
removeAllListeners(): void {
|
||||||
|
this.x.removeAllListeners();
|
||||||
|
this.y.removeAllListeners();
|
||||||
|
this._listeners = {};
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts `{x, y}` into `{left, top}` for use in style, e.g.
|
* Converts `{x, y}` into `{left, top}` for use in style, e.g.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue