Merge branch 'main' of https://gitlab.com/phenomLi/StructV2 into main
This commit is contained in:
commit
0809d1fd53
@ -5,7 +5,7 @@ import { ViewContainer } from "../View/viewContainer";
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 初始化视图拖拽功能
|
*
|
||||||
* @param g6Instance
|
* @param g6Instance
|
||||||
* @param hasLeak
|
* @param hasLeak
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -7,7 +7,7 @@ import { LayoutGroupOptions } from "../options";
|
|||||||
* 在初始化渲染器之后,修正节点拖拽时,外部指针没有跟着动的问题
|
* 在初始化渲染器之后,修正节点拖拽时,外部指针没有跟着动的问题
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
export function FixNodeMarkerDrag(g6Instance: Graph, optionsTable: { [key: string]: LayoutGroupOptions }) {
|
export function FixNodeMarkerDrag(g6Instance: Graph) {
|
||||||
let dragActive: boolean = false;
|
let dragActive: boolean = false;
|
||||||
|
|
||||||
const nodeData = {
|
const nodeData = {
|
||||||
@ -36,16 +36,6 @@ export function FixNodeMarkerDrag(g6Instance: Graph, optionsTable: { [key: strin
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const dragNode = optionsTable[node.layout].behavior.dragNode;
|
|
||||||
|
|
||||||
if (dragNode === false) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Array.isArray(dragNode) && dragNode.find(item => item === node.sourceType) === undefined) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
dragActive = true;
|
dragActive = true;
|
||||||
nodeData.startX = event.canvasX;
|
nodeData.startX = event.canvasX;
|
||||||
nodeData.startY = event.canvasY;
|
nodeData.startY = event.canvasY;
|
||||||
|
|||||||
@ -1,5 +1,4 @@
|
|||||||
import { SVModel } from "../Model/SVModel";
|
import { SVModel } from "../Model/SVModel";
|
||||||
import { LayoutGroupOptions } from "../options";
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -8,15 +7,8 @@ import { LayoutGroupOptions } from "../options";
|
|||||||
* @param optionsTable
|
* @param optionsTable
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export function InitViewBehaviors(optionsTable: { [key: string]: LayoutGroupOptions }) {
|
export function InitViewBehaviors() {
|
||||||
const dragNodeTable: { [key: string]: boolean | string[] } = {},
|
const defaultModes = [];
|
||||||
selectNodeTable: { [key: string]: boolean | string[] } = {},
|
|
||||||
defaultModes = [];
|
|
||||||
|
|
||||||
Object.keys(optionsTable).forEach(item => {
|
|
||||||
dragNodeTable[item] = optionsTable[item].behavior.dragNode;
|
|
||||||
selectNodeTable[item] = optionsTable[item].behavior.selectNode;
|
|
||||||
});
|
|
||||||
|
|
||||||
const dragNodeFilter = event => {
|
const dragNodeFilter = event => {
|
||||||
let g6Item = event.item,
|
let g6Item = event.item,
|
||||||
@ -26,16 +18,6 @@ export function InitViewBehaviors(optionsTable: { [key: string]: LayoutGroupOpti
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
let dragNode = optionsTable[node.layout].behavior.dragNode;
|
|
||||||
|
|
||||||
if (typeof dragNode === 'boolean') {
|
|
||||||
return dragNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Array.isArray(dragNode) && dragNode.indexOf(node.sourceType) > -1) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,16 +29,6 @@ export function InitViewBehaviors(optionsTable: { [key: string]: LayoutGroupOpti
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
let selectNode = optionsTable[node.layout].behavior.selectNode;
|
|
||||||
|
|
||||||
if (typeof selectNode === 'boolean') {
|
|
||||||
return selectNode;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Array.isArray(selectNode) && selectNode.indexOf(node.sourceType) > -1) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,59 +0,0 @@
|
|||||||
import { Graph, IGroup } from "@antv/g6-pc";
|
|
||||||
import { ext } from '@antv/matrix-util';
|
|
||||||
|
|
||||||
const transform = ext.transform;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 初始化视图缩放功能
|
|
||||||
* @param g6Instance
|
|
||||||
* @param generalModelsGroup
|
|
||||||
*/
|
|
||||||
export function InitZoomCanvas(g6Instance: Graph, g6GeneralGroup: IGroup) {
|
|
||||||
const minZoom = 0.2,
|
|
||||||
maxZoom = 2,
|
|
||||||
step = 0.15;
|
|
||||||
|
|
||||||
g6Instance.on('wheel', event => {
|
|
||||||
let delta = event.wheelDelta,
|
|
||||||
matrix = g6GeneralGroup.getMatrix(),
|
|
||||||
center = [event.x, event.y],
|
|
||||||
targetScale = 1;
|
|
||||||
|
|
||||||
if (delta > 0) {
|
|
||||||
targetScale += step;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (delta < 0) {
|
|
||||||
targetScale -= step;
|
|
||||||
}
|
|
||||||
|
|
||||||
matrix = transform(matrix, [
|
|
||||||
['t', -center[0], -center[1]],
|
|
||||||
['s', targetScale, targetScale],
|
|
||||||
['t', center[0], center[1]],
|
|
||||||
]);
|
|
||||||
|
|
||||||
if ((minZoom && matrix[0] < minZoom) || (maxZoom && matrix[0] > maxZoom)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
g6GeneralGroup.setMatrix(matrix);
|
|
||||||
g6Instance.paint();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
31
src/BehaviorHelper/zoomCanvasWithLeak.ts
Normal file
31
src/BehaviorHelper/zoomCanvasWithLeak.ts
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
import { Graph, IGroup } from "@antv/g6-pc";
|
||||||
|
import { ext } from '@antv/matrix-util';
|
||||||
|
|
||||||
|
const transform = ext.transform;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param g6Instance
|
||||||
|
* @param generalModelsGroup
|
||||||
|
*/
|
||||||
|
export function InitZoomCanvasWithLeak(g6Instance: Graph) {
|
||||||
|
g6Instance.on('wheel', event => {
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ export class Renderer {
|
|||||||
},
|
},
|
||||||
fitView: false,
|
fitView: false,
|
||||||
modes: {
|
modes: {
|
||||||
default: InitViewBehaviors(this.engine.optionsTable)
|
default: InitViewBehaviors()
|
||||||
},
|
},
|
||||||
plugins: [tooltip]
|
plugins: [tooltip]
|
||||||
});
|
});
|
||||||
|
|||||||
@ -50,7 +50,7 @@ export class ViewContainer {
|
|||||||
// InitZoomCanvas(g6Instance, g6GeneralGroup);
|
// InitZoomCanvas(g6Instance, g6GeneralGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
FixNodeMarkerDrag(g6Instance, this.engine.optionsTable);
|
FixNodeMarkerDrag(g6Instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -144,10 +144,6 @@ export class ViewContainer {
|
|||||||
|
|
||||||
this.prevLayoutGroupTable = layoutGroupTable;
|
this.prevLayoutGroupTable = layoutGroupTable;
|
||||||
this.prevModelList = modelList;
|
this.prevModelList = modelList;
|
||||||
|
|
||||||
// modelList.forEach(item => {
|
|
||||||
// console.log(item.getModelType(), item.getBound());
|
|
||||||
// });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user