From 14e28f564eed8108c864fddc1a346401a00a5668 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jir=CC=8Ci=CC=81=20Ota=CC=81hal?= Date: Sun, 31 Mar 2019 09:49:29 +1300 Subject: [PATCH] fix: fix run animation after interactions The animation was run even when the value was changed while waiting for interactions. --- src/Scale.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Scale.js b/src/Scale.js index 0ca4f61..720fbf8 100644 --- a/src/Scale.js +++ b/src/Scale.js @@ -19,6 +19,8 @@ class Scale extends PureComponent { const { value, initValue } = props; + this.interaction = null; + this.state = { scaleValue: new Animated.Value(initValue || value), }; @@ -36,8 +38,13 @@ class Scale extends PureComponent { const { value } = this.props; if (value !== nextProps.value) { + if (this.interaction) { + this.interaction.cancel(); + } + if (nextProps.runAfterInteractions) { - InteractionManager.runAfterInteractions().then(() => { + this.interaction = InteractionManager.runAfterInteractions(() => { + this.interaction = null; this.move(nextProps); }); } else {