From c4bb218d334d5a397cfd873014b94ae684291660 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Fri, 6 Dec 2024 10:06:56 +0800 Subject: [PATCH] :art: https://github.com/siyuan-note/siyuan/issues/12708 --- app/src/protyle/render/av/cell.ts | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/app/src/protyle/render/av/cell.ts b/app/src/protyle/render/av/cell.ts index 35892ab50..c5040c7df 100644 --- a/app/src/protyle/render/av/cell.ts +++ b/app/src/protyle/render/av/cell.ts @@ -284,23 +284,19 @@ export const cellScrollIntoView = (blockElement: HTMLElement, cellElement: Eleme const cellRect = cellElement.getBoundingClientRect(); if (!onlyHeight) { const avScrollElement = blockElement.querySelector(".av__scroll"); - if (avScrollElement) { - const avScrollRect = avScrollElement.getBoundingClientRect(); - if (avScrollRect.right < cellRect.right) { - avScrollElement.scrollLeft = avScrollElement.scrollLeft + cellRect.right - avScrollRect.right; - } else { - const rowElement = hasClosestByClassName(cellElement, "av__row"); - if (rowElement) { - const stickyElement = rowElement.querySelector(".av__colsticky"); - if (stickyElement) { - if (!stickyElement.contains(cellElement)) { // https://github.com/siyuan-note/siyuan/issues/12162 - const stickyRight = stickyElement.getBoundingClientRect().right; - if (stickyRight > cellRect.left) { - avScrollElement.scrollLeft = avScrollElement.scrollLeft + cellRect.left - stickyRight; - } - } - } else if (avScrollRect.left > cellRect.left) { - avScrollElement.scrollLeft = avScrollElement.scrollLeft + cellRect.left - avScrollRect.left; + const rowElement = hasClosestByClassName(cellElement, "av__row"); + if (avScrollElement && rowElement) { + const stickyElement = rowElement.querySelector(".av__colsticky"); + if (!stickyElement.contains(cellElement)) { // https://github.com/siyuan-note/siyuan/issues/12162 + const stickyRight = stickyElement.getBoundingClientRect().right; + const avScrollRect = avScrollElement.getBoundingClientRect(); + if (stickyRight > cellRect.left || avScrollRect.right < cellRect.left) { + avScrollElement.scrollLeft = avScrollElement.scrollLeft + cellRect.left - stickyRight; + } else if (stickyRight < cellRect.left && avScrollRect.right < cellRect.right) { + if (cellRect.width + stickyRight > avScrollRect.right) { + avScrollElement.scrollLeft = avScrollElement.scrollLeft + cellRect.left - stickyRight; + } else { + avScrollElement.scrollLeft = avScrollElement.scrollLeft + cellRect.right - avScrollRect.right; } } }