Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save HerbertLim/b39bddf40d987ba24dbe78d7149a8e1d to your computer and use it in GitHub Desktop.
Save HerbertLim/b39bddf40d987ba24dbe78d7149a8e1d to your computer and use it in GitHub Desktop.
slide in and out animation at React Native (the first bad example)
// the first code
Animated.parallel([ // 윈도우를 슬라이드인, 페이드인 한다.
Animated.timing(
this.state.fadeAnim,
{
toValue: 1,
duration: isAndroid ? androidDuration : iosDuration,
easing: Easing.in(),
useNativeDriver,
}
),
Animated.timing(
this.state.transY,
{
toValue: shouldFix ? 0 : -visibleWindowHeight,
duration: isAndroid ? androidDuration : iosDuration,
easing: Easing.elastic(),
useNativeDriver,
}
)
]).start()
this.closeTimer = setTimeout( () => {
this.disableButton = true;
if (!shouldFix) {
this.timer = null; // 정상적으로 타임아웃이 발생하면 timer 객체를 초기화한다
Animated.parallel([
Animated.timing(
this.state.fadeAnim,
{
toValue: 0.01,
duration: isAndroid ? androidDuration : iosDuration,
easing: Easing.back(),
useNativeDriver,
}
),
Animated.timing(
this.state.transY,
{
toValue: 0,
duration: isAndroid ? androidDuration : iosDuration,
easing: Easing.back(),
useNativeDriver,
}
)
]).start()
this.props.closeSimpleAqiGuideNoti()
}
}, timeout)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment