Skip to content

Commit 14e28f5

Browse files
committed
fix: fix run animation after interactions
The animation was run even when the value was changed while waiting for interactions.
1 parent 3c9f34d commit 14e28f5

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/Scale.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ class Scale extends PureComponent {
1919

2020
const { value, initValue } = props;
2121

22+
this.interaction = null;
23+
2224
this.state = {
2325
scaleValue: new Animated.Value(initValue || value),
2426
};
@@ -36,8 +38,13 @@ class Scale extends PureComponent {
3638
const { value } = this.props;
3739

3840
if (value !== nextProps.value) {
41+
if (this.interaction) {
42+
this.interaction.cancel();
43+
}
44+
3945
if (nextProps.runAfterInteractions) {
40-
InteractionManager.runAfterInteractions().then(() => {
46+
this.interaction = InteractionManager.runAfterInteractions(() => {
47+
this.interaction = null;
4148
this.move(nextProps);
4249
});
4350
} else {

0 commit comments

Comments
 (0)