[英]Android React Native Height 0 on Animated.View
We toggle an Animated.View
's height between full height and 0. When we animate the view to height of 0 it automatically re-opens, changing the value to minimize to 1 fixes it but is visible and not desired. 我们将
Animated.View
的高度在全高和0之间切换。将视图设置为0高度时,它会自动重新打开,将值最小化为1可以修复此问题,但可见但不理想。
componentWillUpdate(nextProps) {
if (this.props.visible !== nextProps.visible) {
const newHeight = nextProps.visible ? viewportHeight(100) : 0;
Animated.timing(this.state.height, {
duration: 250,
toValue: newHeight,
});
Animated.timing(this.state.searchBarHeight, {
duration: 150,
toValue: nextProps.visible ? 56 : 0,
}).start();
Animated.timing(this.state.iconBarHeight, {
duration: 150,
toValue: nextProps.visible ? 56 : 0,
}).start();
}
}
事实证明,如果将collapsible
道具添加到View(特定于Android),则会阻止优化代码潜在地将视图从层次结构中删除。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.