From fa4b040583c2da95c7a145fc16fd44c1011eccf8 Mon Sep 17 00:00:00 2001 From: TAEWOONG KANG Date: Mon, 20 Dec 2021 13:48:46 +0900 Subject: [PATCH] =?UTF-8?q?https://github.com/mastermoo/react-native-actio?= =?UTF-8?q?n-button/issues/339=20=EB=B0=A9=EB=B2=95=EC=97=90=20=EB=94=B0?= =?UTF-8?q?=EB=9D=BC=20=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ActionButton.js | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/ActionButton.js b/ActionButton.js index 865352d..a8aac9b 100644 --- a/ActionButton.js +++ b/ActionButton.js @@ -37,7 +37,6 @@ const ActionButton = (props) => { if (props.active) { Animated.spring(anim.current, { toValue: 1, - useNativeDriver: true, }).start(); setActive(true); setResetToken(props.resetToken); @@ -46,7 +45,6 @@ const ActionButton = (props) => { Animated.spring(anim.current, { toValue: 0, - useNativeDriver: true, }).start(); timeout.current = setTimeout(() => { setActive(false); @@ -255,19 +253,32 @@ const ActionButton = (props) => { ////////////////////// const animateButton = (animate = true) => { - if (active) return reset(animate); + if (this.state.active) return this.reset(); if (animate) { - Animated.spring(anim.current, { - toValue: 1, - useNativeDriver: true, - }).start(); + Animated.spring(this.anim, { toValue: 1, useNativeDriver: false }).start(); } else { - anim.current.setValue(1); + this.anim.setValue(1); } - setActive(true); - }; + this.setState({ active: true, resetToken: this.state.resetToken }); + } + + reset(animate = true) { + if (this.props.onReset) this.props.onReset(); + + if (animate) { + Animated.spring(this.anim, { toValue: 0, useNativeDriver: false }).start(); + } else { + this.anim.setValue(0); + } + + setTimeout(() => { + if (this.mounted) { + this.setState({ active: false, resetToken: this.state.resetToken }); + } + }, 250); + } const reset = (animate = true) => { if (props.onReset) props.onReset(); @@ -275,7 +286,6 @@ const ActionButton = (props) => { if (animate) { Animated.spring(anim.current, { toValue: 0, - useNativeDriver: true, }).start(); } else { anim.current.setValue(0);