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