Scroll horizontally with mouse wheel

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev committed 2022-03-16 10:51:54 +03:00
1 parent 7273082048
commit 08477021d1
1 file changed
+9
@@ -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}
>