feat: 目录弹窗自动滚动到当前章节
This commit is contained in:
parent
1e9c551766
commit
8dd946eac8
@ -575,6 +575,14 @@
|
||||
html += `<a href="?id=${ch.id}" class="toc-item ${isCurrent}" data-id="${ch.id}">第${ch.id}章:${ch.title}</a>`;
|
||||
});
|
||||
tocList.innerHTML = html;
|
||||
|
||||
// 自动滚动到当前章节
|
||||
setTimeout(() => {
|
||||
const currentItem = tocList.querySelector('.current');
|
||||
if (currentItem) {
|
||||
currentItem.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
|
||||
// 更新移动端目录高亮
|
||||
|
||||
Loading…
Reference in New Issue
Block a user