Skip to content

Commit

Permalink
mastermoo#339 방법에 따라 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
Taewoong1378 committed Dec 20, 2021
1 parent 5df63d7 commit fa4b040
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions ActionButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ const ActionButton = (props) => {
if (props.active) {
Animated.spring(anim.current, {
toValue: 1,
useNativeDriver: true,
}).start();
setActive(true);
setResetToken(props.resetToken);
Expand All @@ -46,7 +45,6 @@ const ActionButton = (props) => {

Animated.spring(anim.current, {
toValue: 0,
useNativeDriver: true,
}).start();
timeout.current = setTimeout(() => {
setActive(false);
Expand Down Expand Up @@ -255,27 +253,39 @@ 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();

if (animate) {
Animated.spring(anim.current, {
toValue: 0,
useNativeDriver: true,
}).start();
} else {
anim.current.setValue(0);
Expand Down

0 comments on commit fa4b040

Please sign in to comment.