@antv/g-base
Advanced tools
Comparing version 0.1.0-beta.5 to 0.1.0-beta.6
import { IContainer, ICtor, IShape, IGroup, IElement } from '../interfaces'; | ||
import BBox from '../bbox'; | ||
import { ShapeBase, BBox } from '../types'; | ||
import Element from './element'; | ||
@@ -8,3 +8,3 @@ declare abstract class Container extends Element implements IContainer { | ||
getCanvasBBox(): BBox; | ||
abstract getShapeBase(): ICtor<IShape>; | ||
abstract getShapeBase(): ShapeBase; | ||
abstract getGroupBase(): ICtor<IGroup>; | ||
@@ -11,0 +11,0 @@ getDefaultCfg(): { |
import { __extends } from "tslib"; | ||
import BBox from '../bbox'; | ||
import Element from './element'; | ||
@@ -97,8 +96,8 @@ import { isFunction, isObject, each, removeFromArray, upperFirst } from '../util/util'; | ||
} | ||
var box = child.getBBox(); | ||
var box_1 = child.getBBox(); | ||
// 计算 4 个顶点 | ||
var leftTop = child.applyToMatrix([box.minX, box.minY, 1]); | ||
var leftBottom = child.applyToMatrix([box.minX, box.maxY, 1]); | ||
var rightTop = child.applyToMatrix([box.maxX, box.minY, 1]); | ||
var rightBottom = child.applyToMatrix([box.maxX, box.maxY, 1]); | ||
var leftTop = child.applyToMatrix([box_1.minX, box_1.minY, 1]); | ||
var leftBottom = child.applyToMatrix([box_1.minX, box_1.maxY, 1]); | ||
var rightTop = child.applyToMatrix([box_1.maxX, box_1.minY, 1]); | ||
var rightBottom = child.applyToMatrix([box_1.maxX, box_1.maxY, 1]); | ||
// 从中取最小的范围 | ||
@@ -130,3 +129,13 @@ var boxMinX = Math.min(leftTop[0], leftBottom[0], rightTop[0], rightBottom[0]); | ||
} | ||
return BBox.fromRange(minX, minY, maxX, maxY); | ||
var box = { | ||
x: minX, | ||
y: minY, | ||
minX: minX, | ||
minY: minY, | ||
maxX: maxX, | ||
maxY: maxY, | ||
width: maxX - minX, | ||
height: maxY - minY, | ||
}; | ||
return box; | ||
}; | ||
@@ -149,5 +158,5 @@ // 获取画布的包围盒 | ||
} | ||
var box = child.getCanvasBBox(); | ||
xArr.push(box.minX, box.maxX); | ||
yArr.push(box.minY, box.maxY); | ||
var box_2 = child.getCanvasBBox(); | ||
xArr.push(box_2.minX, box_2.maxX); | ||
yArr.push(box_2.minY, box_2.maxY); | ||
} | ||
@@ -166,3 +175,13 @@ }); | ||
} | ||
return BBox.fromRange(minX, minY, maxX, maxY); | ||
var box = { | ||
x: minX, | ||
y: minY, | ||
minX: minX, | ||
minY: minY, | ||
maxX: maxX, | ||
maxY: maxY, | ||
width: maxX - minX, | ||
height: maxY - minY, | ||
}; | ||
return box; | ||
}; | ||
@@ -169,0 +188,0 @@ Container.prototype.getDefaultCfg = function () { |
import { IElement, IShape, IGroup, ICanvas } from '../interfaces'; | ||
import { ClipCfg, ChangeType, ShapeAttrs } from '../types'; | ||
import { ClipCfg, ChangeType, ShapeAttrs, BBox } from '../types'; | ||
import Base from './base'; | ||
import BBox from '../bbox'; | ||
declare abstract class Element extends Base implements IElement { | ||
@@ -6,0 +5,0 @@ /** |
import { IShape } from '../interfaces'; | ||
import { ShapeCfg, ShapeAttrs } from '../types'; | ||
import BBox from '../bbox'; | ||
import { ShapeCfg, ShapeAttrs, BBox } from '../types'; | ||
import Element from './element'; | ||
@@ -5,0 +4,0 @@ declare abstract class AbstractShape extends Element implements IShape { |
import { __extends } from "tslib"; | ||
import BBox from '../bbox'; | ||
import Element from './element'; | ||
@@ -66,3 +65,12 @@ import { multiplyVec2 } from '../util/matrix'; | ||
var maxY = Math.max(topLeft[1], topRight[1], bottomLeft[1], bottomRight[1]); | ||
return BBox.fromRange(minX, minY, maxX, maxY); | ||
return { | ||
x: minX, | ||
y: minY, | ||
minX: minX, | ||
minY: minY, | ||
maxX: maxX, | ||
maxY: maxY, | ||
width: maxX - minX, | ||
height: maxY - minY, | ||
}; | ||
}; | ||
@@ -69,0 +77,0 @@ /** |
@@ -83,6 +83,6 @@ /** | ||
// 至少有一个对象 | ||
for (var i = 1; i < paths.length; i++) { | ||
var group = paths[i]; | ||
for (var i = 0; i < paths.length; i++) { | ||
var element = paths[i]; | ||
// 暂定跟 name 绑定 | ||
var name_1 = group.get('name'); | ||
var name_1 = element.get('name'); | ||
if (name_1) { | ||
@@ -92,3 +92,3 @@ var eventName = name_1 + DELEGATION_SPLIT + type; | ||
eventObj.delegateTarget = container; | ||
eventObj.currentTarget = group; | ||
eventObj.currentTarget = element; | ||
container.emit(eventName, eventObj); | ||
@@ -95,0 +95,0 @@ } |
@@ -6,3 +6,2 @@ /** | ||
export declare const version: any; | ||
export { default as BBox } from './bbox'; | ||
export { default as Event } from './event/graph-event'; | ||
@@ -9,0 +8,0 @@ export { default as Base } from './abstract/base'; |
@@ -7,3 +7,2 @@ /** | ||
export var version = pkg.version; | ||
export { default as BBox } from './bbox'; | ||
export { default as Event } from './event/graph-event'; | ||
@@ -10,0 +9,0 @@ export { default as Base } from './abstract/base'; |
@@ -1,3 +0,2 @@ | ||
import { ShapeCfg, GroupCfg, ClipCfg, Point, ChangeType, AnimateCfg, ElementAttrs, OnFrame } from './types'; | ||
import BBox from './bbox'; | ||
import { ShapeCfg, GroupCfg, ClipCfg, Point, ChangeType, AnimateCfg, ElementAttrs, OnFrame, ShapeBase, BBox } from './types'; | ||
export interface ICtor<T> { | ||
@@ -128,3 +127,3 @@ new (cfg: any): T; | ||
*/ | ||
getBBox(): BBox; | ||
getBBox(): any; | ||
/** | ||
@@ -267,3 +266,3 @@ * 获取图形元素相对画布的包围盒,会计算从顶层到当前的 matrix | ||
*/ | ||
getShapeBase(): ICtor<IShape>; | ||
getShapeBase(): ShapeBase; | ||
/** | ||
@@ -270,0 +269,0 @@ * 获取 Group 的基类,用于添加默认的 Group |
@@ -0,1 +1,12 @@ | ||
import { IShape, ICtor } from './interfaces'; | ||
export declare type BBox = { | ||
x: number; | ||
y: number; | ||
minX: number; | ||
minY: number; | ||
maxX: number; | ||
maxY: number; | ||
width: number; | ||
height: number; | ||
}; | ||
export declare type Point = { | ||
@@ -143,2 +154,5 @@ x: number; | ||
}; | ||
export declare type ShapeBase = { | ||
[key: string]: ICtor<IShape>; | ||
}; | ||
declare type A = ['a' | 'A', number, number, number, number, number, number, number]; | ||
@@ -145,0 +159,0 @@ declare type C = ['c' | 'C', number, number, number, number, number, number]; |
import { IContainer, ICtor, IShape, IGroup, IElement } from '../interfaces'; | ||
import BBox from '../bbox'; | ||
import { ShapeBase, BBox } from '../types'; | ||
import Element from './element'; | ||
@@ -8,3 +8,3 @@ declare abstract class Container extends Element implements IContainer { | ||
getCanvasBBox(): BBox; | ||
abstract getShapeBase(): ICtor<IShape>; | ||
abstract getShapeBase(): ShapeBase; | ||
abstract getGroupBase(): ICtor<IGroup>; | ||
@@ -11,0 +11,0 @@ getDefaultCfg(): { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var bbox_1 = require("../bbox"); | ||
var element_1 = require("./element"); | ||
@@ -99,8 +98,8 @@ var util_1 = require("../util/util"); | ||
} | ||
var box = child.getBBox(); | ||
var box_1 = child.getBBox(); | ||
// 计算 4 个顶点 | ||
var leftTop = child.applyToMatrix([box.minX, box.minY, 1]); | ||
var leftBottom = child.applyToMatrix([box.minX, box.maxY, 1]); | ||
var rightTop = child.applyToMatrix([box.maxX, box.minY, 1]); | ||
var rightBottom = child.applyToMatrix([box.maxX, box.maxY, 1]); | ||
var leftTop = child.applyToMatrix([box_1.minX, box_1.minY, 1]); | ||
var leftBottom = child.applyToMatrix([box_1.minX, box_1.maxY, 1]); | ||
var rightTop = child.applyToMatrix([box_1.maxX, box_1.minY, 1]); | ||
var rightBottom = child.applyToMatrix([box_1.maxX, box_1.maxY, 1]); | ||
// 从中取最小的范围 | ||
@@ -132,3 +131,13 @@ var boxMinX = Math.min(leftTop[0], leftBottom[0], rightTop[0], rightBottom[0]); | ||
} | ||
return bbox_1.default.fromRange(minX, minY, maxX, maxY); | ||
var box = { | ||
x: minX, | ||
y: minY, | ||
minX: minX, | ||
minY: minY, | ||
maxX: maxX, | ||
maxY: maxY, | ||
width: maxX - minX, | ||
height: maxY - minY, | ||
}; | ||
return box; | ||
}; | ||
@@ -151,5 +160,5 @@ // 获取画布的包围盒 | ||
} | ||
var box = child.getCanvasBBox(); | ||
xArr.push(box.minX, box.maxX); | ||
yArr.push(box.minY, box.maxY); | ||
var box_2 = child.getCanvasBBox(); | ||
xArr.push(box_2.minX, box_2.maxX); | ||
yArr.push(box_2.minY, box_2.maxY); | ||
} | ||
@@ -168,3 +177,13 @@ }); | ||
} | ||
return bbox_1.default.fromRange(minX, minY, maxX, maxY); | ||
var box = { | ||
x: minX, | ||
y: minY, | ||
minX: minX, | ||
minY: minY, | ||
maxX: maxX, | ||
maxY: maxY, | ||
width: maxX - minX, | ||
height: maxY - minY, | ||
}; | ||
return box; | ||
}; | ||
@@ -171,0 +190,0 @@ Container.prototype.getDefaultCfg = function () { |
import { IElement, IShape, IGroup, ICanvas } from '../interfaces'; | ||
import { ClipCfg, ChangeType, ShapeAttrs } from '../types'; | ||
import { ClipCfg, ChangeType, ShapeAttrs, BBox } from '../types'; | ||
import Base from './base'; | ||
import BBox from '../bbox'; | ||
declare abstract class Element extends Base implements IElement { | ||
@@ -6,0 +5,0 @@ /** |
import { IShape } from '../interfaces'; | ||
import { ShapeCfg, ShapeAttrs } from '../types'; | ||
import BBox from '../bbox'; | ||
import { ShapeCfg, ShapeAttrs, BBox } from '../types'; | ||
import Element from './element'; | ||
@@ -5,0 +4,0 @@ declare abstract class AbstractShape extends Element implements IShape { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var bbox_1 = require("../bbox"); | ||
var element_1 = require("./element"); | ||
@@ -68,3 +67,12 @@ var matrix_1 = require("../util/matrix"); | ||
var maxY = Math.max(topLeft[1], topRight[1], bottomLeft[1], bottomRight[1]); | ||
return bbox_1.default.fromRange(minX, minY, maxX, maxY); | ||
return { | ||
x: minX, | ||
y: minY, | ||
minX: minX, | ||
minY: minY, | ||
maxX: maxX, | ||
maxY: maxY, | ||
width: maxX - minX, | ||
height: maxY - minY, | ||
}; | ||
}; | ||
@@ -71,0 +79,0 @@ /** |
@@ -85,6 +85,6 @@ "use strict"; | ||
// 至少有一个对象 | ||
for (var i = 1; i < paths.length; i++) { | ||
var group = paths[i]; | ||
for (var i = 0; i < paths.length; i++) { | ||
var element = paths[i]; | ||
// 暂定跟 name 绑定 | ||
var name_1 = group.get('name'); | ||
var name_1 = element.get('name'); | ||
if (name_1) { | ||
@@ -94,3 +94,3 @@ var eventName = name_1 + DELEGATION_SPLIT + type; | ||
eventObj.delegateTarget = container; | ||
eventObj.currentTarget = group; | ||
eventObj.currentTarget = element; | ||
container.emit(eventName, eventObj); | ||
@@ -97,0 +97,0 @@ } |
@@ -6,3 +6,2 @@ /** | ||
export declare const version: any; | ||
export { default as BBox } from './bbox'; | ||
export { default as Event } from './event/graph-event'; | ||
@@ -9,0 +8,0 @@ export { default as Base } from './abstract/base'; |
@@ -9,4 +9,2 @@ "use strict"; | ||
exports.version = pkg.version; | ||
var bbox_1 = require("./bbox"); | ||
exports.BBox = bbox_1.default; | ||
var graph_event_1 = require("./event/graph-event"); | ||
@@ -13,0 +11,0 @@ exports.Event = graph_event_1.default; |
@@ -1,3 +0,2 @@ | ||
import { ShapeCfg, GroupCfg, ClipCfg, Point, ChangeType, AnimateCfg, ElementAttrs, OnFrame } from './types'; | ||
import BBox from './bbox'; | ||
import { ShapeCfg, GroupCfg, ClipCfg, Point, ChangeType, AnimateCfg, ElementAttrs, OnFrame, ShapeBase, BBox } from './types'; | ||
export interface ICtor<T> { | ||
@@ -128,3 +127,3 @@ new (cfg: any): T; | ||
*/ | ||
getBBox(): BBox; | ||
getBBox(): any; | ||
/** | ||
@@ -267,3 +266,3 @@ * 获取图形元素相对画布的包围盒,会计算从顶层到当前的 matrix | ||
*/ | ||
getShapeBase(): ICtor<IShape>; | ||
getShapeBase(): ShapeBase; | ||
/** | ||
@@ -270,0 +269,0 @@ * 获取 Group 的基类,用于添加默认的 Group |
@@ -0,1 +1,12 @@ | ||
import { IShape, ICtor } from './interfaces'; | ||
export declare type BBox = { | ||
x: number; | ||
y: number; | ||
minX: number; | ||
minY: number; | ||
maxX: number; | ||
maxY: number; | ||
width: number; | ||
height: number; | ||
}; | ||
export declare type Point = { | ||
@@ -143,2 +154,5 @@ x: number; | ||
}; | ||
export declare type ShapeBase = { | ||
[key: string]: ICtor<IShape>; | ||
}; | ||
declare type A = ['a' | 'A', number, number, number, number, number, number, number]; | ||
@@ -145,0 +159,0 @@ declare type C = ['c' | 'C', number, number, number, number, number, number]; |
{ | ||
"name": "@antv/g-base", | ||
"version": "0.1.0-beta.5", | ||
"version": "0.1.0-beta.6", | ||
"description": "A common util collection for antv projects", | ||
@@ -59,3 +59,3 @@ "main": "lib/index.js", | ||
"__npminstall_done": false, | ||
"gitHead": "dfe406eabeb080b0200809ee347c03a555f4af91" | ||
"gitHead": "118171c0ea71a649565ec0278c1e41b6a97f2f65" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
537437
98
9342