perf(Typography): fast and efficient syncEllipsis (#7146)

feat-4.1
Nined 2023-12-18 11:21:55 +08:00 committed by GitHub
parent a8a774a5ff
commit 67efafca4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 2 deletions

View File

@ -166,6 +166,7 @@ const Base = defineComponent({
});
onMounted(() => {
state.clientRendered = true;
syncEllipsis();
});
onBeforeUnmount(() => {
@ -180,7 +181,7 @@ const Base = defineComponent({
resizeOnNextFrame();
});
},
{ flush: 'post', deep: true, immediate: true },
{ flush: 'post', deep: true },
);
watchEffect(() => {
@ -296,7 +297,12 @@ const Base = defineComponent({
);
// ============== Ellipsis ==============
function resizeOnNextFrame() {
function resizeOnNextFrame(sizeInfo?: { width: number; height: number }) {
if (sizeInfo) {
const { width, height } = sizeInfo;
if (!width || !height) return;
}
raf.cancel(state.rafId);
state.rafId = raf(() => {
// Do not bind `syncEllipsis`. It need for test usage on prototype