mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-11 20:08:37 +00:00
fix:setTimeout error (#215)
This commit is contained in:
@@ -48,7 +48,7 @@ export class SelectionManager implements VirgoSelection {
|
|||||||
private _scrollDelay = 150;
|
private _scrollDelay = 150;
|
||||||
private _selectEndDelayTime = 500;
|
private _selectEndDelayTime = 500;
|
||||||
private _hasEmitEndPending = false;
|
private _hasEmitEndPending = false;
|
||||||
|
private _scrollTimer: number | null = null;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* the selection info before current
|
* the selection info before current
|
||||||
@@ -681,6 +681,9 @@ export class SelectionManager implements VirgoSelection {
|
|||||||
*/
|
*/
|
||||||
public async activeNodeByNodeId(nodeId: string, position?: CursorTypes) {
|
public async activeNodeByNodeId(nodeId: string, position?: CursorTypes) {
|
||||||
try {
|
try {
|
||||||
|
if (this._scrollTimer) {
|
||||||
|
clearTimeout(this._scrollTimer);
|
||||||
|
}
|
||||||
const node = await this._editor.getBlockById(nodeId);
|
const node = await this._editor.getBlockById(nodeId);
|
||||||
if (node) {
|
if (node) {
|
||||||
this._activatedNodeId = nodeId;
|
this._activatedNodeId = nodeId;
|
||||||
@@ -689,7 +692,7 @@ export class SelectionManager implements VirgoSelection {
|
|||||||
}
|
}
|
||||||
this.emit(nodeId, SelectEventTypes.active, this.lastPoint);
|
this.emit(nodeId, SelectEventTypes.active, this.lastPoint);
|
||||||
// TODO: Optimize the related logic after implementing the scroll bar
|
// TODO: Optimize the related logic after implementing the scroll bar
|
||||||
setTimeout(() => {
|
this._scrollTimer = window.setTimeout(() => {
|
||||||
this._editor.scrollManager.keepBlockInView(node);
|
this._editor.scrollManager.keepBlockInView(node);
|
||||||
}, this._scrollDelay);
|
}, this._scrollDelay);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user