Reactjs 将SwipeableView与updateHeight()一起使用
SwipeableView的新更新允许MaterialUI Tabs组件中的每个选项卡具有自己的高度。让我往后退一点。之前,MaterialUI选项卡组件将显示最长选项卡高度的所有选项卡。这会在不需要的选项卡上创建不必要的滚动。SwipeableViews最近通过将其添加到组件中修复了此问题Reactjs 将SwipeableView与updateHeight()一起使用,reactjs,react-swipeable-views,Reactjs,React Swipeable Views,SwipeableView的新更新允许MaterialUI Tabs组件中的每个选项卡具有自己的高度。让我往后退一点。之前,MaterialUI选项卡组件将显示最长选项卡高度的所有选项卡。这会在不需要的选项卡上创建不必要的滚动。SwipeableViews最近通过将其添加到组件中修复了此问题 <SwipeableViews action={actions => {this.swipeableActions = actions;}}> <div>{'sli
<SwipeableViews
action={actions => {this.swipeableActions = actions;}}>
<div>{'slide n°1'}</div>
<div>{'slide n°2'}</div>
<div>{'slide n°3'}</div>
</SwipeableViews>
修复了标签在加载状态下的高度问题。但是,当项目隐藏并通过单击事件显示时,高度将保持不变,并且显示的项目不会显示(从视图中切断)
查看图像(imgur无法加载图像)改为查看图像链接
您需要添加:
动画重量
到SwipeableViews组件
您可能还必须将函数向下传递给子零部件,以便在子零部件修改视图时更新高度
UpdateSwipeableViewHeight = () => {
if (this.swipeableActions) this.swipeableActions.updateHeight()
};
<SwipeableViews
id="searchTabsSwipeableView"
axis={theme.direction === 'rtl' ? 'x-reverse' : 'x'}
index={activeTabIndex}
onChangeIndex={index => {
this.handleChange(null, index);
this.UpdateSwipeableViewHeight();
}
}
action={actions => (this.swipeableActions = actions)}
animateHeight
>
<div className={classes.swipableViewsComponent}>
<ChildComponent updateHeight={this.UpdateSwipeableViewHeight} />
</div>
updatesweepableviewheight=()=>{
if(this.swipeableActions)this.swipeableActions.updateHeight()
};
{
this.handleChange(null,index);
this.updatesWipeTableViewHeight();
}
}
action={actions=>(this.swipeableActions=actions)}
动画重量
>
UpdateSwipeableViewHeight = () => {
if (this.swipeableActions) this.swipeableActions.updateHeight()
};
<SwipeableViews
id="searchTabsSwipeableView"
axis={theme.direction === 'rtl' ? 'x-reverse' : 'x'}
index={activeTabIndex}
onChangeIndex={index => {
this.handleChange(null, index);
this.UpdateSwipeableViewHeight();
}
}
action={actions => (this.swipeableActions = actions)}
animateHeight
>
<div className={classes.swipableViewsComponent}>
<ChildComponent updateHeight={this.UpdateSwipeableViewHeight} />
</div>