From 63fd23a718914617a131a50fe38dee06bd03ae9d Mon Sep 17 00:00:00 2001 From: kdxcxs Date: Sat, 5 Dec 2020 18:24:56 +0800 Subject: [PATCH] fix(YooForum): now the position of reply is changed with topic title height instead of a fixed value --- src/ui/YooForumTopicUI.js | 7 ++++++- src/ui/YooForumUI.js | 6 +++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/ui/YooForumTopicUI.js b/src/ui/YooForumTopicUI.js index ef8e4ef..7e4e6df 100644 --- a/src/ui/YooForumTopicUI.js +++ b/src/ui/YooForumTopicUI.js @@ -32,6 +32,7 @@ export default class YooForumTopicUI extends Component { this.state = { detailShowing: false, layoutY: 0, + layoutHeight: 0, translate: new Animated.ValueXY({x: 0, y: 0}), }; this.topicHeaderRef = createRef(); @@ -50,6 +51,7 @@ export default class YooForumTopicUI extends Component { this.state.layoutY, this.onAnimationFinished, this.props.replies, + this.state.layoutHeight, ); } else { this.props.hideDetail(this.state.translate, this.onAnimationFinished); @@ -65,7 +67,10 @@ export default class YooForumTopicUI extends Component { ]} onPress={this.onPress} onLayout={(event) => { - this.setState({layoutY: event.nativeEvent.layout.y}); + this.setState({ + layoutY: event.nativeEvent.layout.y, + layoutHeight: event.nativeEvent.layout.height, + }); }}> {this.props.topic.owner} diff --git a/src/ui/YooForumUI.js b/src/ui/YooForumUI.js index c144d91..8dba2ba 100644 --- a/src/ui/YooForumUI.js +++ b/src/ui/YooForumUI.js @@ -90,14 +90,14 @@ export default class YooForumUI extends Component { this.hideDetail = this.hideDetail.bind(this); } - showDetail(translate, layoutY, onAnimationFinished, replies) { + showDetail(translate, layoutY, onAnimationFinished, replies, layoutHeight) { this.replyRef.current.scrollTo({x: 0, y: 0, animated: false}); this.setState({ scrollEnabled: false, currentReplies: replies, }); this.state.replyTranslateY.setValue( - this.state.currentPosition + 100 + screenHeight, + this.state.currentPosition + layoutHeight + screenHeight, ); Animated.parallel([ Animated.timing(translate, { @@ -114,7 +114,7 @@ export default class YooForumUI extends Component { useNativeDriver: true, }), Animated.timing(this.state.replyTranslateY, { - toValue: this.state.currentPosition + 100, + toValue: this.state.currentPosition + layoutHeight + 8, duration: 250, delay: 250, useNativeDriver: true,