fix(tracker): check node scrolls only on start
This commit is contained in:
parent
f78da27562
commit
cea704e1ee
3 changed files with 8 additions and 8 deletions
|
|
@ -1,4 +1,4 @@
|
|||
type NodeCallback = (node: Node) => void;
|
||||
type NodeCallback = (node: Node, isStart: boolean) => void;
|
||||
type ElementListener = [string, EventListener];
|
||||
|
||||
export default class Nodes {
|
||||
|
|
@ -57,8 +57,8 @@ export default class Nodes {
|
|||
}
|
||||
return id;
|
||||
}
|
||||
callNodeCallbacks(node: Node): void {
|
||||
this.nodeCallbacks.forEach((cb) => cb(node));
|
||||
callNodeCallbacks(node: Node, start: boolean): void {
|
||||
this.nodeCallbacks.forEach((cb) => cb(node, start));
|
||||
}
|
||||
getID(node: Node): number | undefined {
|
||||
return (node as any)[this.node_id];
|
||||
|
|
|
|||
|
|
@ -333,12 +333,12 @@ export default abstract class Observer {
|
|||
}
|
||||
return (this.commited[id] = this._commitNode(id, node));
|
||||
}
|
||||
private commitNodes(): void {
|
||||
private commitNodes(isStart: boolean = false): void {
|
||||
let node;
|
||||
this.recents.forEach((type, id) => {
|
||||
this.commitNode(id);
|
||||
if (type === RecentsType.New && (node = this.app.nodes.getNode(id))) {
|
||||
this.app.nodes.callNodeCallbacks(node);
|
||||
this.app.nodes.callNodeCallbacks(node, isStart)
|
||||
}
|
||||
})
|
||||
this.clear();
|
||||
|
|
@ -356,7 +356,7 @@ export default abstract class Observer {
|
|||
});
|
||||
this.bindTree(nodeToBind);
|
||||
beforeCommit(this.app.nodes.getID(node))
|
||||
this.commitNodes();
|
||||
this.commitNodes(true)
|
||||
}
|
||||
|
||||
disconnect(): void {
|
||||
|
|
|
|||
|
|
@ -35,8 +35,8 @@ export default function (app: App): void {
|
|||
nodeScroll.clear();
|
||||
});
|
||||
|
||||
app.nodes.attachNodeCallback(node => {
|
||||
if (isElementNode(node) && node.scrollLeft + node.scrollTop > 0) {
|
||||
app.nodes.attachNodeCallback((node, isStart) => {
|
||||
if (isStart && isElementNode(node) && node.scrollLeft + node.scrollTop > 0) {
|
||||
nodeScroll.set(node, [node.scrollLeft, node.scrollTop]);
|
||||
}
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue