Vanessa 2025-03-10 11:45:43 +08:00
parent aedbd6bee8
commit 626d5ecd32

View File

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