fix: virtual scrollBar not update, close #5124
parent
efa045ab9c
commit
0a5dbf3642
|
@ -1,5 +1,14 @@
|
||||||
import type { Ref } from 'vue';
|
import type { Ref } from 'vue';
|
||||||
import { computed, defineComponent, onBeforeUnmount, onMounted, ref, watch } from 'vue';
|
import {
|
||||||
|
getCurrentInstance,
|
||||||
|
onBeforeUpdate,
|
||||||
|
onBeforeMount,
|
||||||
|
defineComponent,
|
||||||
|
onBeforeUnmount,
|
||||||
|
onMounted,
|
||||||
|
ref,
|
||||||
|
watch,
|
||||||
|
} from 'vue';
|
||||||
import addEventListenerWrap from '../vc-util/Dom/addEventListener';
|
import addEventListenerWrap from '../vc-util/Dom/addEventListener';
|
||||||
import { getOffset } from '../vc-util/Dom/css';
|
import { getOffset } from '../vc-util/Dom/css';
|
||||||
import classNames from '../_util/classNames';
|
import classNames from '../_util/classNames';
|
||||||
|
@ -22,11 +31,22 @@ export default defineComponent<StickyScrollBarProps>({
|
||||||
emits: ['scroll'],
|
emits: ['scroll'],
|
||||||
setup(props, { emit, expose }) {
|
setup(props, { emit, expose }) {
|
||||||
const tableContext = useInjectTable();
|
const tableContext = useInjectTable();
|
||||||
const bodyScrollWidth = computed(() => props.scrollBodyRef.value.scrollWidth || 0);
|
const bodyScrollWidth = ref(0);
|
||||||
const bodyWidth = computed(() => props.scrollBodyRef.value.clientWidth || 0);
|
const bodyWidth = ref(0);
|
||||||
const scrollBarWidth = computed(
|
const scrollBarWidth = ref(0);
|
||||||
() => bodyScrollWidth.value && bodyWidth.value * (bodyWidth.value / bodyScrollWidth.value),
|
const instance = getCurrentInstance();
|
||||||
);
|
const updateSomeValue = () => {
|
||||||
|
bodyScrollWidth.value = props.scrollBodyRef.value.scrollWidth || 0;
|
||||||
|
bodyWidth.value = props.scrollBodyRef.value.clientWidth || 0;
|
||||||
|
scrollBarWidth.value =
|
||||||
|
bodyScrollWidth.value && bodyWidth.value * (bodyWidth.value / bodyScrollWidth.value);
|
||||||
|
};
|
||||||
|
onBeforeMount(() => {
|
||||||
|
updateSomeValue();
|
||||||
|
});
|
||||||
|
onBeforeUpdate(() => {
|
||||||
|
updateSomeValue();
|
||||||
|
});
|
||||||
|
|
||||||
const scrollBarRef = ref();
|
const scrollBarRef = ref();
|
||||||
|
|
||||||
|
@ -100,6 +120,7 @@ export default defineComponent<StickyScrollBarProps>({
|
||||||
isHiddenScrollBar: false,
|
isHiddenScrollBar: false,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
instance.update?.();
|
||||||
};
|
};
|
||||||
|
|
||||||
const setScrollLeft = (left: number) => {
|
const setScrollLeft = (left: number) => {
|
||||||
|
|
Loading…
Reference in New Issue