Skip to content

Commit c1b01b7

Browse files
authoredMar 3, 2025
refactor setCurrent func scroll policy (#14265)
* remove script that should not be added * dummy * refactor the scroll logic * remove kernel binary * revert 9a4d0b9 that casued by unclean git checkout
1 parent aa5d257 commit c1b01b7

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed
 

‎app/src/layout/dock/Files.ts

+7-6
Original file line numberDiff line numberDiff line change
@@ -1108,13 +1108,14 @@ data-type="navigation-root" data-path="/">
11081108
liItem.classList.remove("b3-list-item--focus");
11091109
});
11101110
target.classList.add("b3-list-item--focus");
1111+
11111112
if (isScroll) {
1112-
let offsetTop = target.offsetTop;
1113-
// https://github.com/siyuan-note/siyuan/issues/8749
1114-
if (target.parentElement.classList.contains("file-tree__sliderDown") && target.offsetParent) {
1115-
offsetTop = (target.offsetParent as HTMLElement).offsetTop;
1116-
}
1117-
this.element.scrollTop = offsetTop - this.element.clientHeight / 2 - this.actionsElement.clientHeight;
1113+
const targetRect = target.getBoundingClientRect();
1114+
const containerRect = this.element.getBoundingClientRect();
1115+
1116+
const relativeTop = targetRect.top - containerRect.top + this.element.scrollTop;
1117+
1118+
this.element.scrollTop = relativeTop - this.element.clientHeight / 2 - this.actionsElement.clientHeight;
11181119
}
11191120
}
11201121

0 commit comments

Comments
 (0)
Please sign in to comment.