From c1b01b7fbdd98cd7e65610889a92c59fbfa1a91c Mon Sep 17 00:00:00 2001 From: sommermorgentraum <24917424+zxkmm@users.noreply.github.com> Date: Mon, 3 Mar 2025 18:49:27 +0800 Subject: [PATCH] refactor setCurrent func scroll policy (#14265) * remove script that should not be added * dummy * refactor the scroll logic * remove kernel binary * revert 9a4d0b97d1c430ee63fe204e546b4fce0f8bd23e that casued by unclean git checkout --- app/src/layout/dock/Files.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/app/src/layout/dock/Files.ts b/app/src/layout/dock/Files.ts index 2f82c9da6..942afe096 100644 --- a/app/src/layout/dock/Files.ts +++ b/app/src/layout/dock/Files.ts @@ -1108,13 +1108,14 @@ data-type="navigation-root" data-path="/"> liItem.classList.remove("b3-list-item--focus"); }); target.classList.add("b3-list-item--focus"); + if (isScroll) { - let offsetTop = target.offsetTop; - // https://github.com/siyuan-note/siyuan/issues/8749 - if (target.parentElement.classList.contains("file-tree__sliderDown") && target.offsetParent) { - offsetTop = (target.offsetParent as HTMLElement).offsetTop; - } - this.element.scrollTop = offsetTop - this.element.clientHeight / 2 - this.actionsElement.clientHeight; + const targetRect = target.getBoundingClientRect(); + const containerRect = this.element.getBoundingClientRect(); + + const relativeTop = targetRect.top - containerRect.top + this.element.scrollTop; + + this.element.scrollTop = relativeTop - this.element.clientHeight / 2 - this.actionsElement.clientHeight; } }