Skip to content

Commit a298b00

Browse files
committed
fix: sticky scrollbar show when init
1 parent 9004644 commit a298b00

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

components/vc-table/stickyScrollBar.tsx

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ interface StickyScrollBarProps {
1313
onScroll: (params: { scrollLeft?: number }) => void;
1414
offsetScroll: number;
1515
container: HTMLElement | Window;
16-
scrollBodySizeInfo: { scrollWidth: number; clientWidth: number };
16+
scrollBodySizeInfo: {
17+
scrollWidth: number;
18+
clientWidth: number;
19+
};
1720
}
1821

1922
export default defineComponent<StickyScrollBarProps>({
@@ -40,7 +43,7 @@ export default defineComponent<StickyScrollBarProps>({
4043

4144
const [scrollState, setScrollState] = useLayoutState({
4245
scrollLeft: 0,
43-
isHiddenScrollBar: false,
46+
isHiddenScrollBar: true,
4447
});
4548

4649
const refState = ref({
@@ -135,13 +138,17 @@ export default defineComponent<StickyScrollBarProps>({
135138
onResizeListener = addEventListenerWrap(window, 'resize', onContainerScroll, false);
136139
});
137140

138-
watch(
139-
[scrollBarWidth, isActive],
140-
() => {
141-
onContainerScroll();
142-
},
143-
{ immediate: true },
144-
);
141+
onMounted(() => {
142+
setTimeout(() => {
143+
watch(
144+
[scrollBarWidth, isActive],
145+
() => {
146+
onContainerScroll();
147+
},
148+
{ immediate: true, flush: 'post' },
149+
);
150+
});
151+
});
145152

146153
watch(
147154
() => props.container,

0 commit comments

Comments
 (0)