mirror of
https://github.com/mathuo/dockview
synced 2025-05-04 02:28:26 +00:00
feat: fix sonar bugs
This commit is contained in:
parent
8f49d29bdb
commit
929690e730
@ -62,7 +62,8 @@ export class DefaultGroupPanelView implements IGroupPanelView {
|
||||
}
|
||||
|
||||
updateParentGroup(group: GroupviewPanel, isPanelVisible: boolean): void {
|
||||
// TODO
|
||||
this._content.updateParentGroup(group, isPanelVisible);
|
||||
this._tab?.updateParentGroup(group, isPanelVisible);
|
||||
}
|
||||
|
||||
layout(width: number, height: number): void {
|
||||
|
@ -101,3 +101,24 @@ export function addDisposableListener<K extends keyof HTMLElementEventMap>(
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export class TickDelayedEvent implements IDisposable {
|
||||
private timer: any;
|
||||
|
||||
private readonly _onFired = new Emitter<void>();
|
||||
readonly onEvent = this._onFired.event;
|
||||
|
||||
fire(): void {
|
||||
if (this.timer) {
|
||||
clearTimeout(this.timer);
|
||||
}
|
||||
this.timer = setTimeout(() => {
|
||||
this._onFired.fire();
|
||||
clearTimeout(this.timer);
|
||||
});
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
this._onFired.dispose();
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Emitter, Event } from '../events';
|
||||
import { Emitter, Event, TickDelayedEvent } from '../events';
|
||||
import { getGridLocation, Gridview, IGridView } from './gridview';
|
||||
import { Position } from '../dnd/droptarget';
|
||||
import { CompositeDisposable, IValueDisposable } from '../lifecycle';
|
||||
@ -165,37 +165,35 @@ export abstract class BaseGrid<T extends IGridPanelView>
|
||||
|
||||
this.addDisposables(
|
||||
(() => {
|
||||
/**
|
||||
* TODO Fix this relatively ugly 'merge and delay'
|
||||
*/
|
||||
let timer: any;
|
||||
const tickDelayedEvent = new TickDelayedEvent();
|
||||
|
||||
return this.onGridEvent((event) => {
|
||||
if (
|
||||
[
|
||||
GroupChangeKind.ADD_GROUP,
|
||||
GroupChangeKind.REMOVE_GROUP,
|
||||
GroupChangeKind.ADD_PANEL,
|
||||
GroupChangeKind.REMOVE_PANEL,
|
||||
GroupChangeKind.GROUP_ACTIVE,
|
||||
GroupChangeKind.PANEL_ACTIVE,
|
||||
GroupChangeKind.LAYOUT,
|
||||
].includes(event.kind)
|
||||
) {
|
||||
if (timer) {
|
||||
clearTimeout(timer);
|
||||
return new CompositeDisposable(
|
||||
this.onGridEvent((event) => {
|
||||
if (
|
||||
[
|
||||
GroupChangeKind.ADD_GROUP,
|
||||
GroupChangeKind.REMOVE_GROUP,
|
||||
GroupChangeKind.ADD_PANEL,
|
||||
GroupChangeKind.REMOVE_PANEL,
|
||||
GroupChangeKind.GROUP_ACTIVE,
|
||||
GroupChangeKind.PANEL_ACTIVE,
|
||||
GroupChangeKind.LAYOUT,
|
||||
].includes(event.kind)
|
||||
) {
|
||||
tickDelayedEvent.fire();
|
||||
}
|
||||
timer = setTimeout(() => {
|
||||
this._onDidLayoutChange.fire();
|
||||
clearTimeout(timer);
|
||||
});
|
||||
}
|
||||
});
|
||||
}),
|
||||
tickDelayedEvent.onEvent(() => {
|
||||
this._onDidLayoutChange.fire();
|
||||
}),
|
||||
tickDelayedEvent
|
||||
);
|
||||
})()
|
||||
);
|
||||
}
|
||||
|
||||
public abstract toJSON(): object;
|
||||
|
||||
public abstract fromJSON(data: any): void;
|
||||
|
||||
public setVisible(panel: T, visible: boolean) {
|
||||
|
@ -60,7 +60,7 @@ function flipNode<T extends Node>(
|
||||
return result as T;
|
||||
} else {
|
||||
return new LeafNode(
|
||||
(node as LeafNode).view,
|
||||
node.view,
|
||||
orthogonal(node.orientation),
|
||||
orthogonalSize
|
||||
) as T;
|
||||
@ -161,11 +161,7 @@ export interface IGridView {
|
||||
readonly minimumHeight: number;
|
||||
readonly maximumHeight: number;
|
||||
priority?: LayoutPriority;
|
||||
layout(
|
||||
width: number,
|
||||
height: number
|
||||
// top: number, left: number
|
||||
): void;
|
||||
layout(width: number, height: number): void;
|
||||
toJSON(): object;
|
||||
fromJSON?(json: object): void;
|
||||
snap?: boolean;
|
||||
@ -615,7 +611,6 @@ export class Gridview implements IDisposable {
|
||||
parent.removeChild(index, sizing);
|
||||
|
||||
if (parent.children.length === 0) {
|
||||
// throw new Error('Invalid grid state');
|
||||
return node.view;
|
||||
}
|
||||
|
||||
|
@ -221,7 +221,7 @@ export class Groupview extends CompositeDisposable implements IGroupview {
|
||||
this.accessor.doSetGroupActive(this.parent, true);
|
||||
}),
|
||||
this.contentContainer.onDidBlur(() => {
|
||||
// this._activePanel?.api._ondid
|
||||
// noop
|
||||
}),
|
||||
this.dropTarget.onDrop((event) => {
|
||||
this.handleDropEvent(event.event, event.position);
|
||||
|
@ -165,10 +165,6 @@ export class Paneview extends CompositeDisposable implements IDisposable {
|
||||
}
|
||||
|
||||
public layout(size: number, orthogonalSize: number): void {
|
||||
// for (const paneItem of this.paneItems) {
|
||||
// paneItem.pane.orthogonalSize = orthogonalSize;
|
||||
// }
|
||||
|
||||
this.splitview.layout(size, orthogonalSize);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user