mirror of
https://github.com/wavetermdev/waveterm.git
synced 2024-12-21 16:38:23 +01:00
sync scrolling of the tabbar across views
This commit is contained in:
parent
be7dda55d4
commit
b890bd0ecb
@ -12,7 +12,8 @@ import { OverlayScrollbars } from "overlayscrollbars";
|
||||
import { createRef, memo, useCallback, useEffect, useRef, useState } from "react";
|
||||
import { debounce } from "throttle-debounce";
|
||||
import { IconButton } from "../element/iconbutton";
|
||||
import { WorkspaceService } from "../store/services";
|
||||
import { ObjectService, WorkspaceService } from "../store/services";
|
||||
import { makeORef } from "../store/wos";
|
||||
import { Tab } from "./tab";
|
||||
import "./tabbar.scss";
|
||||
import { UpdateStatusBanner } from "./updatebanner";
|
||||
@ -201,6 +202,10 @@ const TabBar = memo(({ workspace }: TabBarProps) => {
|
||||
setTabIds(newTabIdsArr);
|
||||
setPinnedTabIds(newPinnedTabSet);
|
||||
}
|
||||
if (osInstanceRef.current) {
|
||||
const { viewport } = osInstanceRef.current.elements();
|
||||
viewport.scrollLeft = workspace.meta?.["scroll:offset"] ?? 0;
|
||||
}
|
||||
}, [workspace, tabIds, pinnedTabIds]);
|
||||
|
||||
const saveTabsPosition = useCallback(() => {
|
||||
@ -578,6 +583,11 @@ const TabBar = memo(({ workspace }: TabBarProps) => {
|
||||
if (scrollableRef.current) {
|
||||
const { viewport } = osInstanceRef.current.elements();
|
||||
viewport.scrollLeft = tabIds.length * tabWidthRef.current;
|
||||
fireAndForget(() =>
|
||||
ObjectService.UpdateObjectMeta(makeORef("workspace", workspace.oid), {
|
||||
"scroll:offset": viewport.scrollLeft,
|
||||
})
|
||||
);
|
||||
}
|
||||
}),
|
||||
[tabIds]
|
||||
|
1
frontend/types/gotypes.d.ts
vendored
1
frontend/types/gotypes.d.ts
vendored
@ -494,6 +494,7 @@ declare global {
|
||||
"vdom:correlationid"?: string;
|
||||
"vdom:route"?: string;
|
||||
"vdom:persist"?: boolean;
|
||||
"scroll:offset"?: number;
|
||||
count?: number;
|
||||
};
|
||||
|
||||
|
@ -100,6 +100,8 @@ const (
|
||||
MetaKey_VDomRoute = "vdom:route"
|
||||
MetaKey_VDomPersist = "vdom:persist"
|
||||
|
||||
MetaKey_ScrollOffset = "scroll:offset"
|
||||
|
||||
MetaKey_Count = "count"
|
||||
)
|
||||
|
||||
|
@ -101,6 +101,8 @@ type MetaTSType struct {
|
||||
VDomRoute string `json:"vdom:route,omitempty"`
|
||||
VDomPersist bool `json:"vdom:persist,omitempty"`
|
||||
|
||||
ScrollOffset float64 `json:"scroll:offset,omitempty"`
|
||||
|
||||
Count int `json:"count,omitempty"` // temp for cpu plot. will remove later
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user