From 8cd675a33247b935458c28553c154bbb6f9a4341 Mon Sep 17 00:00:00 2001 From: unanmed <1319491857@qq.com> Date: Wed, 6 Nov 2024 13:42:45 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E6=BB=9A=E5=8A=A8?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E7=9A=84=E6=80=A7=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/scroll.vue | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/src/components/scroll.vue b/src/components/scroll.vue index 96b3547..d422fa7 100644 --- a/src/components/scroll.vue +++ b/src/components/scroll.vue @@ -92,22 +92,30 @@ async function calHeight(first: boolean = false) { if (!first) { await sleep(20); } + const canvas = ctx.canvas; const style2 = getComputedStyle(canvas); - 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') { + 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; + } + } else { main.style.flexDirection = 'column'; - 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`; + 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; + } } + await new Promise(res => { requestAnimationFrame(() => { total =