Skip to content

Commit 5f54256

Browse files
hanashiromcgrue
authored andcommitted
feat: scroll on tabs
1 parent 611bd72 commit 5f54256

File tree

2 files changed

+24
-4
lines changed

2 files changed

+24
-4
lines changed

src/dockable/Window.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,18 @@ function TabBar({
220220
};
221221
}
222222

223+
function onWheel(event: React.WheelEvent<HTMLDivElement>) {
224+
if(!event.shiftKey){
225+
event.currentTarget.scrollLeft += event.deltaY;
226+
}else{
227+
const nextTabId = selected + (event.deltaY > 0 ? 1 : -1);
228+
if (nextTabId < 0 || nextTabId >= widgets.length) return;
229+
const widgetId = (widgets[nextTabId] as any)?.props?.id;
230+
if(widgetId === undefined) return;
231+
onTabClick(nextTabId, widgetId);
232+
}
233+
}
234+
223235
return (
224236
<Droppable droppableId={windowId} type="dockable-tab" direction="horizontal">
225237
{(provided, snapshot) => (
@@ -236,6 +248,7 @@ function TabBar({
236248
<div
237249
ref={provided.innerRef}
238250
className={css.tabSpacer}
251+
onWheel={onWheel}
239252
{...provided.droppableProps}
240253
>
241254
{widgets.map((child: any, i) => {

src/dockable/css/Window.module.css

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,17 @@
171171
}
172172

173173
.tabSpacer {
174-
display: flex;
175-
flex-grow: 1;
176-
flex-shrink: 1;
177-
width: 0;
174+
display: flex;
175+
flex-grow: 1;
176+
flex-shrink: 1;
177+
width: 0;
178+
overflow-x: scroll;
179+
overflow-y: hidden;
180+
scrollbar-width: none;
181+
}
182+
183+
.tabSpacer::-webkit-scrollbar {
184+
height: 0px;
178185
}
179186

180187
.dropBorder {

0 commit comments

Comments
 (0)