Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@antv/g-base

Package Overview
Dependencies
Maintainers
63
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@antv/g-base - npm Package Compare versions

Comparing version 0.5.11 to 0.5.12

1

esm/interfaces.js

@@ -1,2 +0,1 @@

export {};
//# sourceMappingURL=interfaces.js.map

@@ -1,2 +0,1 @@

export {};
//# sourceMappingURL=types.js.map

4

lib/abstract/base.js

@@ -7,3 +7,3 @@ "use strict";

var Base = /** @class */ (function (_super) {
(0, tslib_1.__extends)(Base, _super);
tslib_1.__extends(Base, _super);
function Base(cfg) {

@@ -17,3 +17,3 @@ var _this = _super.call(this) || this;

var defaultCfg = _this.getDefaultCfg();
_this.cfg = (0, util_1.mix)(defaultCfg, cfg);
_this.cfg = util_1.mix(defaultCfg, cfg);
return _this;

@@ -20,0 +20,0 @@ }

@@ -10,6 +10,6 @@ "use strict";

var PX_SUFFIX = 'px';
var browser = (0, detect_browser_1.detect)();
var browser = detect_browser_1.detect();
var isFirefox = browser && browser.name === 'firefox';
var Canvas = /** @class */ (function (_super) {
(0, tslib_1.__extends)(Canvas, _super);
tslib_1.__extends(Canvas, _super);
function Canvas(cfg) {

@@ -37,3 +37,3 @@ var _this = _super.call(this, cfg) || this;

var container = this.get('container');
if ((0, util_1.isString)(container)) {
if (util_1.isString(container)) {
container = document.getElementById(container);

@@ -126,3 +126,3 @@ this.set('container', container);

// For Firefox <= 38
if (isFirefox && !(0, util_1.isNil)(ev.layerX) && ev.layerX !== ev.offsetX) {
if (isFirefox && !util_1.isNil(ev.layerX) && ev.layerX !== ev.offsetX) {
return {

@@ -133,3 +133,3 @@ x: ev.layerX,

}
if (!(0, util_1.isNil)(ev.offsetX)) {
if (!util_1.isNil(ev.offsetX)) {
// For IE6+, Firefox >= 39, Chrome, Safari, Opera

@@ -136,0 +136,0 @@ return {

@@ -55,3 +55,3 @@ "use strict";

}
(0, util_2.removeFromArray)(container.getChildren(), element);
util_2.removeFromArray(container.getChildren(), element);
}

@@ -65,3 +65,3 @@ function getComparer(compare) {

var Container = /** @class */ (function (_super) {
(0, tslib_1.__extends)(Container, _super);
tslib_1.__extends(Container, _super);
function Container() {

@@ -87,3 +87,3 @@ return _super !== null && _super.apply(this, arguments) || this;

if (children.length > 0) {
(0, util_2.each)(children, function (child) {
util_2.each(children, function (child) {
var box = child.getBBox();

@@ -93,6 +93,6 @@ xArr.push(box.minX, box.maxX);

});
minX = (0, util_1.min)(xArr);
maxX = (0, util_1.max)(xArr);
minY = (0, util_1.min)(yArr);
maxY = (0, util_1.max)(yArr);
minX = util_1.min(xArr);
maxX = util_1.max(xArr);
minY = util_1.min(yArr);
maxY = util_1.max(yArr);
}

@@ -130,3 +130,3 @@ else {

if (children.length > 0) {
(0, util_2.each)(children, function (child) {
util_2.each(children, function (child) {
var box = child.getCanvasBBox();

@@ -136,6 +136,6 @@ xArr.push(box.minX, box.maxX);

});
minX = (0, util_1.min)(xArr);
maxX = (0, util_1.max)(xArr);
minY = (0, util_1.min)(yArr);
maxY = (0, util_1.max)(yArr);
minX = util_1.min(xArr);
maxX = util_1.max(xArr);
minY = util_1.min(yArr);
maxY = util_1.max(yArr);
}

@@ -187,3 +187,3 @@ else {

var children = this.getChildren();
(0, util_2.each)(children, function (child) {
util_2.each(children, function (child) {
child.applyMatrix(totalMatrix);

@@ -200,3 +200,3 @@ });

var cfg = args[1];
if ((0, util_2.isObject)(type)) {
if (util_2.isObject(type)) {
cfg = type;

@@ -209,3 +209,3 @@ }

if (!shapeType) {
shapeType = (0, util_2.upperFirst)(cfg.type);
shapeType = util_2.upperFirst(cfg.type);
SHAPE_MAP[cfg.type] = shapeType;

@@ -225,3 +225,3 @@ }

var group;
if ((0, util_2.isFunction)(groupClass)) {
if (util_2.isFunction(groupClass)) {
if (cfg) {

@@ -257,3 +257,3 @@ group = new groupClass(cfg);

// 如果不支持拾取,则直接返回
if (!(0, util_2.isAllowCapture)(this)) {
if (!util_2.isAllowCapture(this)) {
return null;

@@ -281,3 +281,3 @@ }

var child = children[i];
if ((0, util_2.isAllowCapture)(child)) {
if (util_2.isAllowCapture(child)) {
if (child.isGroup()) {

@@ -329,3 +329,3 @@ shape = child.getShape(x, y, ev);

// 稳定排序
(0, util_2.each)(children, function (child, index) {
util_2.each(children, function (child, index) {
child[INDEX] = index;

@@ -418,3 +418,3 @@ return child;

var children = this.getChildren();
(0, util_2.each)(children, function (element) {
util_2.each(children, function (element) {
if (fn(element)) {

@@ -437,3 +437,3 @@ rst.push(element);

var children = this.getChildren();
(0, util_2.each)(children, function (element) {
util_2.each(children, function (element) {
if (fn(element)) {

@@ -440,0 +440,0 @@ rst = element;

@@ -21,3 +21,3 @@ "use strict";

for (var i = 0; i < arr.length; i++) {
if ((0, util_1.isArray)(arr[i])) {
if (util_1.isArray(arr[i])) {
result.push([].concat(arr[i]));

@@ -42,4 +42,4 @@ }

var attrs = shape.attr();
(0, util_1.each)(props, function (v, k) {
if (RESERVED_PORPS.indexOf(k) === -1 && !(0, util_1.isEqual)(attrs[k], v)) {
util_1.each(props, function (v, k) {
if (RESERVED_PORPS.indexOf(k) === -1 && !util_1.isEqual(attrs[k], v)) {
toAttrs[k] = v;

@@ -56,6 +56,6 @@ }

var hasOwnProperty = Object.prototype.hasOwnProperty;
(0, util_1.each)(animations, function (item) {
util_1.each(animations, function (item) {
// 后一个动画开始执行的时间 < 前一个动画的结束时间 && 后一个动画的执行时间 > 前一个动画的延迟
if (startTime + delay < item.startTime + item.delay + item.duration && duration > item.delay) {
(0, util_1.each)(animation.toAttrs, function (v, k) {
util_1.each(animation.toAttrs, function (v, k) {
if (hasOwnProperty.call(item.toAttrs, k)) {

@@ -71,3 +71,3 @@ delete item.toAttrs[k];

var Element = /** @class */ (function (_super) {
(0, tslib_1.__extends)(Element, _super);
tslib_1.__extends(Element, _super);
function Element(cfg) {

@@ -82,3 +82,3 @@ var _this = _super.call(this, cfg) || this;

var attrs = _this.getDefaultAttrs();
(0, util_1.mix)(attrs, cfg.attrs);
util_1.mix(attrs, cfg.attrs);
_this.attrs = attrs;

@@ -145,3 +145,3 @@ _this.initAttrs(attrs);

return this.attrs;
if ((0, util_1.isObject)(name)) {
if (util_1.isObject(name)) {
for (var k in name) {

@@ -255,3 +255,3 @@ this.setAttr(k, name[k]);

if (parent) {
(0, util_2.removeFromArray)(parent.getChildren(), this);
util_2.removeFromArray(parent.getChildren(), this);
if (!parent.get('clearing')) {

@@ -287,3 +287,3 @@ // 如果父元素正在清理,当前元素不触发 remove

if (parentMatrix && currentMatrix) {
totalMatrix = (0, matrix_1.multiplyMatrix)(parentMatrix, currentMatrix);
totalMatrix = matrix_1.multiplyMatrix(parentMatrix, currentMatrix);
}

@@ -302,3 +302,3 @@ else {

if (matrix && currentMatrix) {
totalMatrix = (0, matrix_1.multiplyMatrix)(matrix, currentMatrix);
totalMatrix = matrix_1.multiplyMatrix(matrix, currentMatrix);
}

@@ -323,3 +323,3 @@ else {

if (matrix) {
return (0, matrix_1.multiplyVec2)(matrix, v);
return matrix_1.multiplyVec2(matrix, v);
}

@@ -332,5 +332,5 @@ return v;

if (matrix) {
var invertMatrix = (0, matrix_1.invert)(matrix);
var invertMatrix = matrix_1.invert(matrix);
if (invertMatrix) {
return (0, matrix_1.multiplyVec2)(invertMatrix, v);
return matrix_1.multiplyVec2(invertMatrix, v);
}

@@ -354,3 +354,3 @@ }

var ShapeBase = this.getShapeBase();
var shapeType = (0, util_1.upperFirst)(clipCfg.type);
var shapeType = util_1.upperFirst(clipCfg.type);
var Cons = ShapeBase[shapeType];

@@ -384,4 +384,4 @@ if (Cons) {

var attrs = {};
(0, util_1.each)(originAttrs, function (i, k) {
if ((0, util_1.isArray)(originAttrs[k])) {
util_1.each(originAttrs, function (i, k) {
if (util_1.isArray(originAttrs[k])) {
attrs[k] = _cloneArrayAttr(originAttrs[k]);

@@ -396,3 +396,3 @@ }

var clone = new cons({ attrs: attrs });
(0, util_1.each)(CLONE_CFGS, function (cfgName) {
util_1.each(CLONE_CFGS, function (cfgName) {
clone.set(cfgName, _this.get(cfgName));

@@ -458,7 +458,7 @@ });

// 第二个参数,既可以是动画最终状态 toAttrs,也可以是自定义帧动画函数 onFrame
if ((0, util_1.isFunction)(toAttrs)) {
if (util_1.isFunction(toAttrs)) {
onFrame = toAttrs;
toAttrs = {};
}
else if ((0, util_1.isObject)(toAttrs) && toAttrs.onFrame) {
else if (util_1.isObject(toAttrs) && toAttrs.onFrame) {
// 兼容 3.0 中的写法,onFrame 和 repeat 可在 toAttrs 中设置

@@ -469,3 +469,3 @@ onFrame = toAttrs.onFrame;

// 第二个参数,既可以是执行时间 duration,也可以是动画参数 animateCfg
if ((0, util_1.isObject)(duration)) {
if (util_1.isObject(duration)) {
animateCfg = duration;

@@ -483,3 +483,3 @@ duration = animateCfg.duration;

// 第四个参数,既可以是回调函数 callback,也可以是延迟时间 delay
if ((0, util_1.isNumber)(callback)) {
if (util_1.isNumber(callback)) {
delay = callback;

@@ -489,3 +489,3 @@ callback = null;

// 第三个参数,既可以是缓动参数 easing,也可以是回调函数 callback
if ((0, util_1.isFunction)(easing)) {
if (util_1.isFunction(easing)) {
callback = easing;

@@ -510,3 +510,3 @@ easing = 'easeLinear';

startTime: timeline.getTime(),
id: (0, util_1.uniqueId)(),
id: util_1.uniqueId(),
onFrame: onFrame,

@@ -536,3 +536,3 @@ pathFormatted: false,

var animations = this.get('animations');
(0, util_1.each)(animations, function (animation) {
util_1.each(animations, function (animation) {
// 将动画执行到最后一帧

@@ -562,3 +562,3 @@ if (toEnd) {

var pauseTime = timeline.getTime();
(0, util_1.each)(animations, function (animation) {
util_1.each(animations, function (animation) {
animation._paused = true;

@@ -587,3 +587,3 @@ animation._pauseTime = pauseTime;

// 之后更新属性需要计算动画已经执行的时长,如果暂停了,就把初始时间调后
(0, util_1.each)(animations, function (animation) {
util_1.each(animations, function (animation) {
animation.startTime = animation.startTime + (current - pauseTime);

@@ -628,7 +628,7 @@ animation._paused = false;

relativeShape &&
(0, util_2.isParent)(element, relativeShape)) {
util_2.isParent(element, relativeShape)) {
return "break";
}
if ((0, util_1.isArray)(name_1)) {
(0, util_1.each)(name_1, function (subName) {
if (util_1.isArray(name_1)) {
util_1.each(name_1, function (subName) {
_this.emitDelegateEvent(element, subName, eventObj);

@@ -635,0 +635,0 @@ });

@@ -6,3 +6,3 @@ "use strict";

var AbstractGroup = /** @class */ (function (_super) {
(0, tslib_1.__extends)(AbstractGroup, _super);
tslib_1.__extends(AbstractGroup, _super);
function AbstractGroup() {

@@ -9,0 +9,0 @@ return _super !== null && _super.apply(this, arguments) || this;

@@ -7,3 +7,3 @@ "use strict";

var AbstractShape = /** @class */ (function (_super) {
(0, tslib_1.__extends)(AbstractShape, _super);
tslib_1.__extends(AbstractShape, _super);
function AbstractShape(cfg) {

@@ -58,6 +58,6 @@ return _super.call(this, cfg) || this;

if (totalMatrix) {
var topLeft = (0, matrix_1.multiplyVec2)(totalMatrix, [bbox.minX, bbox.minY]);
var topRight = (0, matrix_1.multiplyVec2)(totalMatrix, [bbox.maxX, bbox.minY]);
var bottomLeft = (0, matrix_1.multiplyVec2)(totalMatrix, [bbox.minX, bbox.maxY]);
var bottomRight = (0, matrix_1.multiplyVec2)(totalMatrix, [bbox.maxX, bbox.maxY]);
var topLeft = matrix_1.multiplyVec2(totalMatrix, [bbox.minX, bbox.minY]);
var topRight = matrix_1.multiplyVec2(totalMatrix, [bbox.maxX, bbox.minY]);
var bottomLeft = matrix_1.multiplyVec2(totalMatrix, [bbox.minX, bbox.maxY]);
var bottomRight = matrix_1.multiplyVec2(totalMatrix, [bbox.maxX, bbox.maxY]);
minX = Math.min(topLeft[0], topRight[0], bottomLeft[0], bottomRight[0]);

@@ -64,0 +64,0 @@ maxX = Math.max(topLeft[0], topRight[0], bottomLeft[0], bottomRight[0]);

@@ -25,3 +25,3 @@ "use strict";

for (var k in toAttrs) {
if (!(0, util_1.isEqual)(fromAttrs[k], toAttrs[k])) {
if (!util_1.isEqual(fromAttrs[k], toAttrs[k])) {
if (k === 'path') {

@@ -52,4 +52,4 @@ var toPath = toAttrs[k];

for (var j = 0; j < toPathPoint.length; j++) {
if ((0, util_1.isNumber)(toPathPoint[j]) && fromPathPoint && (0, util_1.isNumber)(fromPathPoint[j])) {
interf = (0, d3_interpolate_1.interpolate)(fromPathPoint[j], toPathPoint[j]);
if (util_1.isNumber(toPathPoint[j]) && fromPathPoint && util_1.isNumber(fromPathPoint[j])) {
interf = d3_interpolate_1.interpolate(fromPathPoint[j], toPathPoint[j]);
cPathPoint.push(interf(ratio));

@@ -69,12 +69,12 @@ }

*/
var matrixFn = (0, d3_interpolate_1.interpolateArray)(fromAttrs[k] || IDENTITY_MATRIX, toAttrs[k] || IDENTITY_MATRIX);
var matrixFn = d3_interpolate_1.interpolateArray(fromAttrs[k] || IDENTITY_MATRIX, toAttrs[k] || IDENTITY_MATRIX);
var currentMatrix = matrixFn(ratio);
cProps[k] = currentMatrix;
}
else if ((0, color_1.isColorProp)(k) && (0, color_1.isGradientColor)(toAttrs[k])) {
else if (color_1.isColorProp(k) && color_1.isGradientColor(toAttrs[k])) {
cProps[k] = toAttrs[k];
}
else if (!(0, util_1.isFunction)(toAttrs[k])) {
else if (!util_1.isFunction(toAttrs[k])) {
// 非函数类型的值才能做插值
interf = (0, d3_interpolate_1.interpolate)(fromAttrs[k], toAttrs[k]);
interf = d3_interpolate_1.interpolate(fromAttrs[k], toAttrs[k]);
cProps[k] = interf(ratio);

@@ -102,3 +102,3 @@ }

var easing = animation.easing;
var easeFn = (0, register_1.getEasing)(easing);
var easeFn = register_1.getEasing(easing);
// 已执行时间

@@ -105,0 +105,0 @@ elapsed = elapsed - startTime - animation.delay;

@@ -15,12 +15,12 @@ "use strict";

var ellipse_1 = require("./ellipse");
(0, register_1.register)('rect', rect_1.default);
(0, register_1.register)('image', rect_1.default); // image 使用 rect 的包围盒计算
(0, register_1.register)('circle', circle_1.default);
(0, register_1.register)('marker', circle_1.default); // marker 使用 circle 的计算方案
(0, register_1.register)('polyline', polyline_1.default);
(0, register_1.register)('polygon', polygon_1.default);
(0, register_1.register)('text', text_1.default);
(0, register_1.register)('path', path_1.default);
(0, register_1.register)('line', line_1.default);
(0, register_1.register)('ellipse', ellipse_1.default);
register_1.register('rect', rect_1.default);
register_1.register('image', rect_1.default); // image 使用 rect 的包围盒计算
register_1.register('circle', circle_1.default);
register_1.register('marker', circle_1.default); // marker 使用 circle 的计算方案
register_1.register('polyline', polyline_1.default);
register_1.register('polygon', polygon_1.default);
register_1.register('text', text_1.default);
register_1.register('path', path_1.default);
register_1.register('line', line_1.default);
register_1.register('ellipse', ellipse_1.default);
//# sourceMappingURL=index.js.map

@@ -17,3 +17,3 @@ "use strict";

};
bbox = (0, util_1.mergeArrowBBox)(shape, bbox);
bbox = util_1.mergeArrowBBox(shape, bbox);
return {

@@ -20,0 +20,0 @@ x: bbox.minX,

@@ -45,6 +45,6 @@ "use strict";

yArr = yArr.filter(function (item) { return !Number.isNaN(item) && item !== Infinity && item !== -Infinity; });
var minX = (0, util_1.min)(xArr);
var minY = (0, util_1.min)(yArr);
var maxX = (0, util_1.max)(xArr);
var maxY = (0, util_1.max)(yArr);
var minX = util_1.min(xArr);
var minY = util_1.min(yArr);
var maxX = util_1.max(xArr);
var maxY = util_1.max(yArr);
if (segmentsWithAngle.length === 0) {

@@ -95,3 +95,3 @@ return {

// 注意: 由于计算精度问题,夹角为 0 的情况计算出来的角度可能是一个很小的值,还需要判断其与 0 是否近似相等
if (!currentAngle || Math.sin(currentAngle) === 0 || (0, util_1.isNumberEqual)(currentAngle, 0)) {
if (!currentAngle || Math.sin(currentAngle) === 0 || util_1.isNumberEqual(currentAngle, 0)) {
return {

@@ -121,3 +121,3 @@ xExtra: 0,

var lineWidth = stroke ? attrs.lineWidth : 0; // 只有有 stroke 时,lineWidth 才生效
var segments = shape.get('segments') || (0, path_util_1.path2Segments)(path);
var segments = shape.get('segments') || path_util_1.path2Segments(path);
var _a = getPathBox(segments, lineWidth), x = _a.x, y = _a.y, width = _a.width, height = _a.height;

@@ -130,3 +130,3 @@ var bbox = {

};
bbox = (0, util_2.mergeArrowBBox)(shape, bbox);
bbox = util_2.mergeArrowBBox(shape, bbox);
return {

@@ -133,0 +133,0 @@ x: bbox.minX,

@@ -22,3 +22,3 @@ "use strict";

};
bbox = (0, util_1.mergeArrowBBox)(shape, bbox);
bbox = util_1.mergeArrowBBox(shape, bbox);
return {

@@ -25,0 +25,0 @@ x: bbox.minX,

@@ -10,5 +10,5 @@ "use strict";

// 如果未组装 font
font = (0, text_1.assembleFont)(attrs);
font = text_1.assembleFont(attrs);
}
var width = (0, text_1.getTextWidth)(text, font);
var width = text_1.getTextWidth(text, font);
var bbox;

@@ -26,3 +26,3 @@ if (!width) {

var textAlign = attrs.textAlign, textBaseline = attrs.textBaseline;
var height = (0, text_1.getTextHeight)(text, fontSize, lineHeight); // attrs.height
var height = text_1.getTextHeight(text, fontSize, lineHeight); // attrs.height
// 默认左右对齐:left, 默认上下对齐 bottom

@@ -29,0 +29,0 @@ var point = {

@@ -66,3 +66,3 @@ "use strict";

// 如果相关图形同当前图形在同一个容器内,不触发事件
if (relativeShape && (0, util_1.isParent)(container, relativeShape)) {
if (relativeShape && util_1.isParent(container, relativeShape)) {
// 阻止继续向上冒泡

@@ -141,3 +141,3 @@ eventObj.bubbles = false;

var el = this.canvas.get('el');
(0, util_1.each)(EVENTS, function (eventName) {
util_1.each(EVENTS, function (eventName) {
el.addEventListener(eventName, _this._eventCallback);

@@ -157,3 +157,3 @@ });

var el = this.canvas.get('el');
(0, util_1.each)(EVENTS, function (eventName) {
util_1.each(EVENTS, function (eventName) {
el.removeEventListener(eventName, _this._eventCallback);

@@ -160,0 +160,0 @@ });

@@ -7,8 +7,8 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.version = exports.registerEasing = exports.getOffScreenContext = exports.invert = exports.multiplyVec2 = exports.isAllowCapture = exports.assembleFont = exports.getTextHeight = exports.registerBBox = exports.getBBoxMethod = exports.PathUtil = exports.AbstractShape = exports.AbstractGroup = exports.AbstractCanvas = exports.Base = exports.Event = void 0;
exports.version = exports.PathUtil = void 0;
var tslib_1 = require("tslib");
var PathUtil = require("./util/path");
exports.PathUtil = PathUtil;
(0, tslib_1.__exportStar)(require("./types"), exports);
(0, tslib_1.__exportStar)(require("./interfaces"), exports);
tslib_1.__exportStar(require("./types"), exports);
tslib_1.__exportStar(require("./interfaces"), exports);
var graph_event_1 = require("./event/graph-event");

@@ -15,0 +15,0 @@ Object.defineProperty(exports, "Event", { enumerable: true, get: function () { return graph_event_1.default; } });

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isGradientColor = exports.isColorProp = void 0;
var isColorProp = function (prop) { return ['fill', 'stroke', 'fillStyle', 'strokeStyle'].includes(prop); };
exports.isColorProp = isColorProp;
var isGradientColor = function (val) { return /^[r,R,L,l]{1}[\s]*\(/.test(val); };
exports.isGradientColor = isGradientColor;
exports.isColorProp = function (prop) { return ['fill', 'stroke', 'fillStyle', 'strokeStyle'].includes(prop); };
exports.isGradientColor = function (val) { return /^[r,R,L,l]{1}[\s]*\(/.test(val); };
//# sourceMappingURL=color.js.map

@@ -13,3 +13,3 @@ "use strict";

}
if ((0, util_1.isArray)(pathString)) {
if (util_1.isArray(pathString)) {
return pathString;

@@ -757,3 +757,3 @@ }

var bezierBBox = function (p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y) {
if (!(0, util_1.isArray)(p1x)) {
if (!util_1.isArray(p1x)) {
p1x = [p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y];

@@ -1078,3 +1078,3 @@ }

var result = true;
(0, util_1.each)(obj1, function (item, i) {
util_1.each(obj1, function (item, i) {
if (item !== obj2[i]) {

@@ -1081,0 +1081,0 @@ result = false;

@@ -14,3 +14,3 @@ "use strict";

var lineCount = 1;
if ((0, util_1.isString)(text)) {
if (util_1.isString(text)) {
lineCount = text.split('\n').length;

@@ -40,6 +40,6 @@ }

function getTextWidth(text, font) {
var context = (0, offscreen_1.getOffScreenContext)(); // 获取离屏的 ctx 进行计算
var context = offscreen_1.getOffScreenContext(); // 获取离屏的 ctx 进行计算
var width = 0;
// null 或者 undefined 时,宽度为 0
if ((0, util_1.isNil)(text) || text === '') {
if (util_1.isNil(text) || text === '') {
return width;

@@ -49,5 +49,5 @@ }

context.font = font;
if ((0, util_1.isString)(text) && text.includes('\n')) {
if (util_1.isString(text) && text.includes('\n')) {
var textArr = text.split('\n');
(0, util_1.each)(textArr, function (subText) {
util_1.each(textArr, function (subText) {
var measureWidth = context.measureText(subText).width;

@@ -54,0 +54,0 @@ if (width < measureWidth) {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isAllowCapture = exports.isParent = exports.upperFirst = exports.each = exports.mix = exports.isArray = exports.isObject = exports.isString = exports.isFunction = exports.isNil = exports.isBrowser = exports.removeFromArray = void 0;
exports.isAllowCapture = exports.isParent = exports.isBrowser = exports.removeFromArray = void 0;
function removeFromArray(arr, obj) {

@@ -5,0 +5,0 @@ var index = arr.indexOf(obj);

{
"name": "@antv/g-base",
"version": "0.5.11",
"version": "0.5.12",
"description": "A common util collection for antv projects",

@@ -57,3 +57,3 @@ "main": "lib/index.js",

"@antv/event-emitter": "^0.1.1",
"@antv/g-math": "^0.1.6",
"@antv/g-math": "^0.1.9",
"@antv/matrix-util": "^3.1.0-beta.1",

@@ -64,7 +64,8 @@ "@antv/path-util": "~2.0.5",

"d3-ease": "^1.0.5",
"d3-interpolate": "^1.3.2",
"d3-interpolate": "^3.0.1",
"d3-timer": "^1.0.9",
"detect-browser": "^5.1.0",
"tslib": "^2.0.3"
}
},
"gitHead": "2d3bf5b25fb8412c05d53f04fc0cd8414d1fd7cc"
}

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

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc