fix: bug修复
This commit is contained in:
parent
34679ff328
commit
aa9381c9c2
2
dist/sv.js
vendored
2
dist/sv.js
vendored
File diff suppressed because one or more lines are too long
@ -11,15 +11,21 @@ import { ViewContainer } from "../View/viewContainer";
|
|||||||
*/
|
*/
|
||||||
export function InitDragCanvasWithLeak(viewContainer: ViewContainer) {
|
export function InitDragCanvasWithLeak(viewContainer: ViewContainer) {
|
||||||
let g6Instance = viewContainer.getG6Instance(),
|
let g6Instance = viewContainer.getG6Instance(),
|
||||||
|
isDragStart = false,
|
||||||
startPositionY = 0,
|
startPositionY = 0,
|
||||||
currentLeakAreaY = 0;
|
currentLeakAreaY = 0;
|
||||||
|
|
||||||
g6Instance.on('canvas:dragstart', event => {
|
g6Instance.on('canvas:dragstart', event => {
|
||||||
|
isDragStart = true;
|
||||||
startPositionY = event.canvasY;
|
startPositionY = event.canvasY;
|
||||||
currentLeakAreaY = viewContainer.leakAreaY;
|
currentLeakAreaY = viewContainer.leakAreaY;
|
||||||
});
|
});
|
||||||
|
|
||||||
g6Instance.on('canvas:drag', event => {
|
g6Instance.on('canvas:drag', event => {
|
||||||
|
if(!isDragStart) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
let zoom = g6Instance.getZoom(),
|
let zoom = g6Instance.getZoom(),
|
||||||
dy = (event.canvasY - startPositionY) / zoom,
|
dy = (event.canvasY - startPositionY) / zoom,
|
||||||
leakAreaY = currentLeakAreaY + dy;
|
leakAreaY = currentLeakAreaY + dy;
|
||||||
@ -34,6 +40,7 @@ export function InitDragCanvasWithLeak(viewContainer: ViewContainer) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
g6Instance.on('canvas:dragend', event => {
|
g6Instance.on('canvas:dragend', event => {
|
||||||
|
isDragStart = false;
|
||||||
startPositionY = 0;
|
startPositionY = 0;
|
||||||
})
|
})
|
||||||
}
|
}
|
@ -1,10 +1,10 @@
|
|||||||
import { Util } from '@antv/g6';
|
import { Util, Item } from '@antv/g6';
|
||||||
|
|
||||||
|
|
||||||
export type animationConfig = {
|
export type animationConfig = {
|
||||||
duration: number;
|
duration: number;
|
||||||
timingFunction: string;
|
timingFunction: string;
|
||||||
callback?: Function;
|
callback?: () => void;
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ export const Animations = {
|
|||||||
* @param G6Item
|
* @param G6Item
|
||||||
* @param animationConfig
|
* @param animationConfig
|
||||||
*/
|
*/
|
||||||
APPEND(G6Item: any, animationConfig: animationConfig) {
|
APPEND(G6Item: Item, animationConfig: animationConfig) {
|
||||||
const type = G6Item.getType(),
|
const type = G6Item.getType(),
|
||||||
group = G6Item.getContainer(),
|
group = G6Item.getContainer(),
|
||||||
Mat3 = Util.mat3,
|
Mat3 = Util.mat3,
|
||||||
@ -54,7 +54,7 @@ export const Animations = {
|
|||||||
* @param G6Item
|
* @param G6Item
|
||||||
* @param animationConfig
|
* @param animationConfig
|
||||||
*/
|
*/
|
||||||
REMOVE(G6Item: any, animationConfig: animationConfig) {
|
REMOVE(G6Item: Item, animationConfig: animationConfig) {
|
||||||
const type = G6Item.getType(),
|
const type = G6Item.getType(),
|
||||||
group = G6Item.getContainer(),
|
group = G6Item.getContainer(),
|
||||||
Mat3 = Util.mat3,
|
Mat3 = Util.mat3,
|
||||||
@ -84,7 +84,7 @@ export const Animations = {
|
|||||||
* @param G6Item
|
* @param G6Item
|
||||||
* @param animationConfig
|
* @param animationConfig
|
||||||
*/
|
*/
|
||||||
FADE_IN(G6Item: any, animationConfig: animationConfig) {
|
FADE_IN(G6Item: Item, animationConfig: animationConfig) {
|
||||||
const group = G6Item.getContainer(),
|
const group = G6Item.getContainer(),
|
||||||
animateCfg = {
|
animateCfg = {
|
||||||
duration: animationConfig.duration,
|
duration: animationConfig.duration,
|
||||||
|
@ -186,8 +186,8 @@ export class LayoutProvider {
|
|||||||
|
|
||||||
// 左往右布局
|
// 左往右布局
|
||||||
for (let i = 0; i < modelGroupList.length; i++) {
|
for (let i = 0; i < modelGroupList.length; i++) {
|
||||||
group = modelGroupList[i],
|
group = modelGroupList[i];
|
||||||
bound = group.getPaddingBound(this.viewOptions.groupPadding);
|
bound = group.getPaddingBound(this.viewOptions.groupPadding);
|
||||||
|
|
||||||
if (prevBound) {
|
if (prevBound) {
|
||||||
dx = prevBound.x + prevBound.width - bound.x;
|
dx = prevBound.x + prevBound.width - bound.x;
|
||||||
@ -231,7 +231,7 @@ export class LayoutProvider {
|
|||||||
height = this.viewContainer.getG6Instance().getHeight(),
|
height = this.viewContainer.getG6Instance().getHeight(),
|
||||||
leakAreaHeightRatio = this.engine.viewOptions.leakAreaHeight;
|
leakAreaHeightRatio = this.engine.viewOptions.leakAreaHeight;
|
||||||
|
|
||||||
if(this.viewContainer.hasLeak) {
|
if (this.viewContainer.hasLeak) {
|
||||||
height = height * (1 - leakAreaHeightRatio);
|
height = height * (1 - leakAreaHeightRatio);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import { SVModel } from "../Model/SVModel";
|
|||||||
import { Renderer } from "./renderer";
|
import { Renderer } from "./renderer";
|
||||||
import { Reconcile } from "./reconcile";
|
import { Reconcile } from "./reconcile";
|
||||||
import { FixNodeMarkerDrag } from "../BehaviorHelper/fixNodeMarkerDrag";
|
import { FixNodeMarkerDrag } from "../BehaviorHelper/fixNodeMarkerDrag";
|
||||||
import { InitDragCanvasWithLeak } from "../BehaviorHelper/dragCanavsWithLeak";
|
import { InitDragCanvasWithLeak } from "../BehaviorHelper/dragCanvasWithLeak";
|
||||||
import { EventBus } from "../Common/eventBus";
|
import { EventBus } from "../Common/eventBus";
|
||||||
import { Group } from "../Common/group";
|
import { Group } from "../Common/group";
|
||||||
|
|
||||||
@ -144,6 +144,10 @@ export class ViewContainer {
|
|||||||
|
|
||||||
this.prevLayoutGroupTable = layoutGroupTable;
|
this.prevLayoutGroupTable = layoutGroupTable;
|
||||||
this.prevModelList = modelList;
|
this.prevModelList = modelList;
|
||||||
|
|
||||||
|
// modelList.forEach(item => {
|
||||||
|
// console.log(item.getModelType(), item.getBound());
|
||||||
|
// });
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -10,7 +10,7 @@ import { SVMarker } from "./Model/SVMarker";
|
|||||||
|
|
||||||
|
|
||||||
export class Engine {
|
export class Engine {
|
||||||
private modelConstructor: ModelConstructor = null;
|
private modelConstructor: ModelConstructor;
|
||||||
private viewContainer: ViewContainer
|
private viewContainer: ViewContainer
|
||||||
private prevStringSourceData: string;
|
private prevStringSourceData: string;
|
||||||
|
|
||||||
@ -50,12 +50,6 @@ export class Engine {
|
|||||||
Object.keys(SV.registeredLayout).forEach(layout => {
|
Object.keys(SV.registeredLayout).forEach(layout => {
|
||||||
if(this.optionsTable[layout] === undefined) {
|
if(this.optionsTable[layout] === undefined) {
|
||||||
const options: LayoutGroupOptions = SV.registeredLayout[layout].defineOptions();
|
const options: LayoutGroupOptions = SV.registeredLayout[layout].defineOptions();
|
||||||
|
|
||||||
options.behavior = Object.assign({
|
|
||||||
dragNode: true,
|
|
||||||
selectNode: true
|
|
||||||
}, options.behavior);
|
|
||||||
|
|
||||||
this.optionsTable[layout] = options;
|
this.optionsTable[layout] = options;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -73,10 +67,6 @@ export class Engine {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.viewContainer.getG6Instance().isAnimating()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let stringSourceData = JSON.stringify(sourceData);
|
let stringSourceData = JSON.stringify(sourceData);
|
||||||
if(this.prevStringSourceData === stringSourceData) {
|
if(this.prevStringSourceData === stringSourceData) {
|
||||||
return;
|
return;
|
||||||
@ -202,12 +192,12 @@ export class Engine {
|
|||||||
* 使用id查找某个节点
|
* 使用id查找某个节点
|
||||||
* @param id
|
* @param id
|
||||||
*/
|
*/
|
||||||
public findElement(id: string) {
|
public findNode(id: string): SVNode {
|
||||||
const elements = this.getNodes();
|
const nodes = this.getNodes();
|
||||||
const stringId = id.toString();
|
const stringId = id.toString();
|
||||||
const targetElement = elements.find(item => item.sourceId === stringId);
|
const targetNode = nodes.find(item => item.sourceId === stringId);
|
||||||
|
|
||||||
return targetElement;
|
return targetNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -71,24 +71,16 @@ export interface MarkerOption extends NodeOption {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export interface LayoutOptions {
|
export interface LayoutOptions {
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export interface BehaviorOptions {
|
|
||||||
dragNode: boolean | string[];
|
|
||||||
selectNode: boolean | string[];
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
export interface LayoutGroupOptions {
|
export interface LayoutGroupOptions {
|
||||||
node: { [key: string]: NodeOption };
|
node: { [key: string]: NodeOption };
|
||||||
link?: { [key: string]: LinkOption }
|
link?: { [key: string]: LinkOption }
|
||||||
marker?: { [key: string]: MarkerOption }
|
marker?: { [key: string]: MarkerOption }
|
||||||
layout?: LayoutOptions;
|
layout?: LayoutOptions;
|
||||||
behavior?: BehaviorOptions;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user