Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion src/Tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ export interface TabsProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'o
moreIcon?: React.ReactNode;
/** @private Internal usage. Not promise will rename in future */
moreTransitionName?: string;

allowScrollCrossTabOnTouchMove?: boolean;
}

function parseTabList(children: React.ReactNode): Tab[] {
Expand Down Expand Up @@ -110,6 +112,7 @@ function Tabs(
onChange,
onTabClick,
onTabScroll,
allowScrollCrossTabOnTouchMove,
...restProps
}: TabsProps,
ref: React.Ref<HTMLDivElement>,
Expand Down Expand Up @@ -215,12 +218,24 @@ function Tabs(
style: tabBarStyle,
panes: children,
};

if (renderTabBar) {
tabNavBar = renderTabBar(tabNavBarProps, TabNavList);
} else {
tabNavBar = <TabNavList {...tabNavBarProps} />;
}

useEffect(() => {
if(allowScrollCrossTabOnTouchMove){
const rcTabsNav : Element | undefined = document.getElementsByClassName('rc-tabs-nav')[0];
if(rcTabsNav){
rcTabsNav.addEventListener('touchmove', function(ev){
ev.stopPropagation();
})
}
}

}, []);

return (
<TabContext.Provider value={{ tabs, prefixCls }}>
Expand Down