Refactor setCurrentById of Outline func scroll policy (#14312)

* scroll for outline

* remove kernel bin

* remove debug print

* gitignore
This commit is contained in:
sommermorgentraum 2025-03-10 11:41:05 +08:00 committed by GitHub
parent e472f71ebd
commit aedbd6bee8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 1 deletions

1
.gitignore vendored
View File

@ -14,6 +14,7 @@ app/stage/build
app/build
app/src/types/dist
app/kernel*
app/SiYuan-Kernel
ios
pprof

View File

@ -485,7 +485,12 @@ export class Outline extends Model {
}
if (currentElement) {
currentElement.classList.add("b3-list-item--focus");
this.element.scrollTop = currentElement.offsetTop - this.element.clientHeight / 2 - 30;
const targetRect = currentElement.getBoundingClientRect();
const containerRect = this.element.getBoundingClientRect();
const relativeTop = targetRect.top - containerRect.top + this.element.scrollTop;
this.element.scrollTop = relativeTop - this.element.clientHeight / 2 - 30;
}
}