feat: 增加框选功能
This commit is contained in:
@@ -266,6 +266,8 @@ export class Reconcile {
|
||||
timingFunction
|
||||
});
|
||||
}
|
||||
|
||||
item.G6Item.enableCapture(false);
|
||||
});
|
||||
|
||||
EventBus.emit('onLeak', leakModels);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Engine } from '../engine';
|
||||
import { SVModel } from '../Model/SVModel';
|
||||
import { Util } from '../Common/util';
|
||||
import { Tooltip, Graph, GraphData } from '@antv/g6';
|
||||
import { InitViewBehaviors } from '../BehaviorHelper/initViewBehaviors';
|
||||
import { Tooltip, Graph, GraphData, Modes } from '@antv/g6';
|
||||
import { InitG6Behaviors } from '../BehaviorHelper/initG6Behaviors';
|
||||
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ export class Renderer {
|
||||
private g6Instance: Graph; // g6 实例
|
||||
private shadowG6Instance: Graph;
|
||||
|
||||
constructor(engine: Engine, DOMContainer: HTMLElement) {
|
||||
constructor(engine: Engine, DOMContainer: HTMLElement, behaviorsModes: Modes) {
|
||||
this.engine = engine;
|
||||
|
||||
const enable: boolean = this.engine.animationOptions.enable,
|
||||
@@ -53,9 +53,7 @@ export class Renderer {
|
||||
easing: timingFunction
|
||||
},
|
||||
fitView: false,
|
||||
modes: {
|
||||
default: InitViewBehaviors()
|
||||
},
|
||||
modes: behaviorsModes,
|
||||
plugins: [tooltip]
|
||||
});
|
||||
}
|
||||
@@ -69,7 +67,7 @@ export class Renderer {
|
||||
private getTooltipContent(model: SVModel, items: { [key: string]: string }): HTMLDivElement {
|
||||
const wrapper = document.createElement('div');
|
||||
|
||||
if(model === null || model === undefined) {
|
||||
if (model === null || model === undefined) {
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
|
||||
+24
-15
@@ -5,12 +5,12 @@ import { Util } from "../Common/util";
|
||||
import { SVModel } from "../Model/SVModel";
|
||||
import { Renderer } from "./renderer";
|
||||
import { Reconcile } from "./reconcile";
|
||||
import { FixNodeMarkerDrag } from "../BehaviorHelper/fixNodeMarkerDrag";
|
||||
import { InitDragCanvasWithLeak } from "../BehaviorHelper/dragCanvasWithLeak";
|
||||
import { EventBus } from "../Common/eventBus";
|
||||
import { InitZoomCanvasWithLeak } from "../BehaviorHelper/zoomCanvasWithLeak";
|
||||
import { Group } from "../Common/group";
|
||||
import { Graph } from "_@antv_g6-pc@0.5.0@@antv/g6-pc";
|
||||
import { Graph, Modes } from "@antv/g6-pc";
|
||||
import { InitG6Behaviors } from "../BehaviorHelper/initG6Behaviors";
|
||||
import { SVNode } from "../Model/SVNode";
|
||||
import { SolveBrushSelectDrag, SolveDragCanvasWithLeak, SolveNodeAppendagesDrag, SolveZoomCanvasWithLeak } from "../BehaviorHelper/behaviorIssueHelper";
|
||||
|
||||
|
||||
|
||||
@@ -26,33 +26,35 @@ export class ViewContainer {
|
||||
|
||||
public hasLeak: boolean;
|
||||
public leakAreaY: number;
|
||||
public brushSelectedModels: SVModel[]; // 保存框选过程中被选中的节点
|
||||
public clickSelectNode: SVNode; // 点击选中的节点
|
||||
|
||||
|
||||
constructor(engine: Engine, DOMContainer: HTMLElement) {
|
||||
const behaviorsModes: Modes = InitG6Behaviors(engine, this);
|
||||
|
||||
this.engine = engine;
|
||||
this.layoutProvider = new LayoutProvider(engine, this);
|
||||
this.renderer = new Renderer(engine, DOMContainer);
|
||||
this.renderer = new Renderer(engine, DOMContainer, behaviorsModes);
|
||||
this.reconcile = new Reconcile(engine, this.renderer);
|
||||
this.prevLayoutGroupTable = new Map();
|
||||
this.prevModelList = [];
|
||||
this.accumulateLeakModels = [];
|
||||
this.hasLeak = false; // 判断是否已经发生过泄漏
|
||||
this.brushSelectedModels = [];
|
||||
this.clickSelectNode = null;
|
||||
|
||||
const g6Instance = this.renderer.getG6Instance(),
|
||||
leakAreaHeight = this.engine.viewOptions.leakAreaHeight,
|
||||
height = this.getG6Instance().getHeight(),
|
||||
{ drag, zoom } = this.engine.interactionOptions;
|
||||
{ drag, zoom } = this.engine.behaviorOptions;
|
||||
|
||||
this.leakAreaY = height - leakAreaHeight;
|
||||
|
||||
if (drag) {
|
||||
InitDragCanvasWithLeak(this);
|
||||
}
|
||||
|
||||
if (zoom) {
|
||||
// InitZoomCanvasWithLeak(this);
|
||||
}
|
||||
|
||||
FixNodeMarkerDrag(g6Instance);
|
||||
SolveNodeAppendagesDrag(this);
|
||||
SolveBrushSelectDrag(this);
|
||||
drag && SolveDragCanvasWithLeak(this);
|
||||
zoom && SolveZoomCanvasWithLeak(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -93,6 +95,13 @@ export class ViewContainer {
|
||||
return this.accumulateLeakModels;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
getLayoutGroupTable(): LayoutGroupTable {
|
||||
return this.prevLayoutGroupTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新视图
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user