Skip to content

Commit

Permalink
🎨 fix #10716
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed Mar 27, 2024
1 parent 65d6779 commit 57d2cd1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
5 changes: 4 additions & 1 deletion app/src/protyle/scroll/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,17 @@ export class Scroll {
});
}

public updateIndex(protyle: IProtyle, id: string) {
public updateIndex(protyle: IProtyle, id: string, cb?:(index: number) => void) {
fetchPost("/api/block/getBlockIndex", {id}, (response) => {
if (!response.data) {
return;
}
const inputElement = protyle.scroll.element.querySelector(".b3-slider") as HTMLInputElement;
inputElement.value = response.data;
protyle.scroll.element.setAttribute("aria-label", `Blocks ${response.data}/${protyle.block.blockCount}`);
if (cb) {
cb(response.data);
}
});
}

Expand Down
13 changes: 8 additions & 5 deletions app/src/protyle/util/onGet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,14 @@ const setHTML = (options: {
}
if (options.scrollAttr && !protyle.scroll.element.classList.contains("fn__none") && !protyle.element.classList.contains("fn__none")) {
// 使用动态滚动条定位到最后一个块,重启后无法触发滚动事件,需要再次更新 index
protyle.scroll.updateIndex(protyle, options.scrollAttr.startId);
// https://github.com/siyuan-note/siyuan/issues/8224
if (protyle.contentElement.scrollHeight <= protyle.contentElement.clientHeight) {
showMessage(window.siyuan.languages.scrollGetMore);
}
protyle.scroll.updateIndex(protyle, options.scrollAttr.startId, (index) => {
// https://github.com/siyuan-note/siyuan/issues/8224
// https://github.com/siyuan-note/siyuan/issues/10716
if (index > 1 && protyle.block.blockCount > 1 && protyle.contentElement.scrollHeight <= protyle.contentElement.clientHeight) {
showMessage(window.siyuan.languages.scrollGetMore);
}
});

}
protyle.app.plugins.forEach(item => {
item.eventBus.emit("loaded-protyle", protyle); // 准备废弃
Expand Down

0 comments on commit 57d2cd1

Please sign in to comment.