fix(canvas): 适应内容时避开底部输入框区域居中

This commit is contained in:
2026-10-12 15:13:53 +08:00
parent 1f329bfbe1
commit 62365568e9
@@ -672,7 +672,10 @@ function onDblClick(e) {
function fitToContent() { function fitToContent() {
const r = stageEl.value?.getBoundingClientRect() const r = stageEl.value?.getBoundingClientRect()
const sw = r ? r.width : 800 const sw = r ? r.width : 800
const sh = r ? r.height : 600 // 底部悬浮输入框会遮住舞台下缘:把它的高度从可用区域里扣掉,内容避开输入框居中
const dockEl = document.querySelector('.cv-dock')
const dockH = dockEl ? dockEl.getBoundingClientRect().height + 32 : 0
const sh = Math.max(120, (r ? r.height : 600) - dockH)
const nodes = props.nodes const nodes = props.nodes
if (!nodes.length) { if (!nodes.length) {
setViewport({ x: 0, y: 0, scale: 1 }) setViewport({ x: 0, y: 0, scale: 1 })