fix(plugin): use rxjs throttle
This commit is contained in:
@@ -1,12 +1,15 @@
|
|||||||
import { BlockDomInfo, HookType } from '@toeverything/framework/virgo';
|
import {
|
||||||
|
BlockDomInfo,
|
||||||
|
HookType,
|
||||||
|
BlockDropPlacement,
|
||||||
|
} from '@toeverything/framework/virgo';
|
||||||
import { StrictMode } from 'react';
|
import { StrictMode } from 'react';
|
||||||
import { BasePlugin } from '../../base-plugin';
|
import { BasePlugin } from '../../base-plugin';
|
||||||
import { ignoreBlockTypes } from './menu-config';
|
import { ignoreBlockTypes } from './menu-config';
|
||||||
import { LineInfoSubject, LeftMenuDraggable } from './LeftMenuDraggable';
|
import { LineInfoSubject, LeftMenuDraggable } from './LeftMenuDraggable';
|
||||||
import { PluginRenderRoot } from '../../utils';
|
import { PluginRenderRoot } from '../../utils';
|
||||||
import { Subject } from 'rxjs';
|
import { Subject, throttleTime } from 'rxjs';
|
||||||
import { domToRect, last, Point, throttle } from '@toeverything/utils';
|
import { domToRect, last, Point } from '@toeverything/utils';
|
||||||
import { BlockDropPlacement } from '@toeverything/framework/virgo';
|
|
||||||
const DRAG_THROTTLE_DELAY = 150;
|
const DRAG_THROTTLE_DELAY = 150;
|
||||||
export class LeftMenuPlugin extends BasePlugin {
|
export class LeftMenuPlugin extends BasePlugin {
|
||||||
private _mousedown?: boolean;
|
private _mousedown?: boolean;
|
||||||
@@ -58,15 +61,10 @@ export class LeftMenuPlugin extends BasePlugin {
|
|||||||
this.hooks.get(HookType.ON_ROOTNODE_DROP).subscribe(this._onDrop)
|
this.hooks.get(HookType.ON_ROOTNODE_DROP).subscribe(this._onDrop)
|
||||||
);
|
);
|
||||||
this.sub.add(
|
this.sub.add(
|
||||||
this.hooks.get(HookType.ON_ROOTNODE_DRAG_OVER).subscribe(
|
this.hooks
|
||||||
throttle(
|
.get(HookType.ON_ROOTNODE_DRAG_OVER)
|
||||||
this._handleRootNodeDragover.bind(this),
|
.pipe(throttleTime(DRAG_THROTTLE_DELAY))
|
||||||
DRAG_THROTTLE_DELAY,
|
.subscribe(this._handleRootNodeDragover)
|
||||||
{
|
|
||||||
leading: true,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user