fix: 优化滚动组件的性能

This commit is contained in:
unanmed 2024-11-06 13:42:45 +08:00
parent e9b9e4b069
commit 8cd675a332

View File

@ -92,22 +92,30 @@ async function calHeight(first: boolean = false) {
if (!first) {
await sleep(20);
}
const canvas = ctx.canvas;
const style2 = getComputedStyle(canvas);
if (!props.type || props.type === 'vertical') {
if (props.noScroll) {
canvas.style.width = `0px`;
} else {
canvas.style.width = `${width}px`;
canvas.width = width * scale;
canvas.height = parseFloat(style2.height) * scale;
if (props.noScroll) canvas.style.width = `0px`;
if (props.type === 'horizontal') {
}
} else {
main.style.flexDirection = 'column';
if (props.noScroll) {
canvas.style.height = `0px`;
} else {
canvas.style.height = `${width}px`;
canvas.style.width = '98%';
canvas.style.margin = '0 1% 0 1%';
canvas.width = parseFloat(style2.width) * scale;
canvas.height = width * scale;
if (props.noScroll) canvas.style.height = `0px`;
}
}
await new Promise<void>(res => {
requestAnimationFrame(() => {
total =