This commit is contained in:
Vanessa 2022-09-03 12:53:41 +08:00
parent 39b4587eb5
commit 29e91e3a96
3 changed files with 9 additions and 9 deletions

View file

@ -5,7 +5,6 @@ import {fetchPost} from "../../util/fetch";
export class Scroll {
public element: HTMLElement;
private inputElement: HTMLInputElement;
public blockSize: number;
public lastScrollTop: number;
public keepLazyLoad: boolean;
@ -22,7 +21,7 @@ export class Scroll {
this.lastScrollTop = 0;
this.inputElement = divElement.firstElementChild as HTMLInputElement;
this.inputElement.addEventListener("input", () => {
this.element.setAttribute("aria-label", `Blocks ${this.inputElement.value}/${this.blockSize}`);
this.element.setAttribute("aria-label", `Blocks ${this.inputElement.value}/${protyle.block.blockCount}`);
});
/// #if BROWSER
this.inputElement.addEventListener("change", () => {
@ -52,16 +51,15 @@ export class Scroll {
});
}
public update(blockSize: number, protyle: IProtyle) {
if (typeof blockSize === "number") {
this.blockSize = blockSize;
this.inputElement.setAttribute("max", this.blockSize.toString());
this.element.setAttribute("aria-label", `Blocks ${this.inputElement.value}/${this.blockSize}`);
public update(protyle: IProtyle) {
if (typeof protyle.block.blockCount === "number") {
this.inputElement.setAttribute("max", protyle.block.blockCount.toString());
this.element.setAttribute("aria-label", `Blocks ${this.inputElement.value}/${protyle.block.blockCount}`);
}
if (protyle.block.showAll) {
this.element.classList.add("fn__none");
} else {
if (blockSize > Constants.SIZE_GET) {
if (protyle.block.childBlockCount > Constants.SIZE_GET) {
this.element.classList.remove("fn__none");
} else {
this.element.classList.add("fn__none");

View file

@ -70,6 +70,7 @@ export const onGet = (data: IWebSocketData, protyle: IProtyle, action: string[]
protyle.block.showAll = false;
protyle.block.mode = data.data.mode;
protyle.block.blockCount = data.data.blockCount;
protyle.block.childBlockCount = data.data.childBlockCount;
protyle.block.action = action;
if (!action.includes(Constants.CB_GET_UNCHANGEID)) {
protyle.block.id = data.data.id;
@ -177,7 +178,7 @@ const setHTML = (options: { content: string, action?: string[], unScroll?: boole
return;
}
if (protyle.options.render.scroll) {
protyle.scroll.update(protyle.block.blockCount, protyle);
protyle.scroll.update(protyle);
}
if (options.action.includes(Constants.CB_GET_HL) && !options.unScroll) {
preventScroll(protyle); // 搜索页签滚动会导致再次请求

View file

@ -389,6 +389,7 @@ interface IProtyle {
id: string,
block: {
id?: string,
childBlockCount?: number,
parentID?: string,
parent2ID?: string,
rootID?: string,