我有一个ListView
组件可以动画并扩展到整个屏幕。由于 ListView 已经贬值,我试图迁移到 Flatlist。ListView 组件如下所示:
<AnimatedListView
horizontal={true}
pagingEnabled={!this.state.isDocked}
style={this.getListViewStyle()}
{...this._panResponder.panHandlers}
dataSource={this.state.dataSource}
enableEmptySections={true}
renderRow={this._renderCard}
initialListSize={10}
scrollRenderAheadDistance={5}
/>;
现在这里的风格是这样应用的:
getListViewStyle() {
return [
styles.container,
{
width: this.state.dockAnimation.interpolate({
inputRange: [0, 1],
outputRange: [
Dimensions.get("window").width,
Dimensions.get("window").width * 2
]
// extrapolate: 'clamp'
})
},
{
transform: [
{
scale: this.state.dockAnimation.interpolate({
inputRange: [0, 1],
outputRange: [1, 0.5]
// extrapolate: 'clamp'
})
},
{
translateX: this.state.dockAnimation.interpolate({
inputRange: [0, 1],
outputRange: [0, -Dimensions.get("window").width]
// extrapolate: 'clamp'
})
},
{
translateY: this.state.dockAnimation.interpolate({
inputRange: [0, 1],
outputRange: [0, Dimensions.get("window").height / 2]
// extrapolate: 'clamp'
})
}
]
}
];
}
panHandeler 看起来像这样 -
this._panResponder = PanResponder.create({
onStartShouldSetPanResponder: (evt, gestureState) => {
return true;
},
onStartShouldSetPanResponderCapture: (evt, gestureState) => {
return true;
},
onMoveShouldSetPanResponder: (evt, gestureState) => {
return true;
},
onMoveShouldSetPanResponderCapture: (evt, gestureState) => {
return true;
},
onPanResponderGrant: () => {},
onPanResponderMove: Animated.event([
null,
{ dx: this.state.pan.x, dy: this.state.pan.y }
]),
onPanResponderRelease: (evt, gestureState) => {
let shouldToggle = this.state.isDocked
? gestureState.dy < -panDiff / 3
: gestureState.dy > panDiff / 3;
if (!shouldToggle) {
// return to original position
Animated.spring(this.state.pan.y, {
toValue: this.state.isDocked ? 0 : 0
}).start();
} else {
// toggle between docked and zoomed
Animated.spring(this.state.pan.y, {
toValue: this.state.isDocked ? -panDiff : panDiff
}).start(() => {
this.setState({
isDocked: !this.state.isDocked,
dockAnimation: !this.state.isDocked
? this.state.pan.y.interpolate({
inputRange: [-panDiff, 0],
outputRange: [0, 1],
extrapolate: "clamp"
})
: this.state.pan.y.interpolate({
inputRange: [0, panDiff],
outputRange: [0, 1],
extrapolate: "clamp"
})
});
});
}
}
});
当我使用将其转换为平面列表时
let AminatedFlatlist = Animated.createAnimatedComponent(Flatlist)
父界面出现,但平面列表不呈现。
调试器甚至没有抛出任何错误。
谁能告诉我如何将上面的列表视图转换为平面列表