1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Scroll horizontally with mouse wheel

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev 2022-03-16 10:51:54 +03:00
parent 7273082048
commit 08477021d1

View File

@ -61,6 +61,14 @@ export const DockTabs = ({ tabs, autoFocus, selectedTab, onChangeTab }: DockTabs
setShowScrollbar(allTabsShrinked);
};
const scrollTabsWithMouseWheel = (left: number) => {
elem.current?.children[0]?.scrollBy({ left });
};
const onMouseWheel = (event: React.WheelEvent) => {
scrollTabsWithMouseWheel(event.deltaY);
};
useEffect(() => {
const cssVars = cssVar(elem.current);
@ -82,6 +90,7 @@ export const DockTabs = ({ tabs, autoFocus, selectedTab, onChangeTab }: DockTabs
autoFocus={autoFocus}
value={selectedTab}
onChange={onChangeTab}
onWheel={onMouseWheel}
scrollable={showScrollbar}
className={styles.tabs}
>