Socket
Socket
Sign inDemoInstall

@antv/g

Package Overview
Dependencies
Maintainers
7
Versions
350
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@antv/g - npm Package Compare versions

Comparing version 3.1.0-beta.6 to 3.1.0-beta.7

dist/g-3.1.0-beta.7.min.js

59

lib/core/element.js

@@ -118,7 +118,10 @@ var Util = require('../util/index');

if (parent) {
if (el) {
parent._cfg.tobeRemoved.push(el);
}
Util.remove(parent.get('children'), this);
}
if (el) {
/* if (el) {
el.parentNode.removeChild(el);
}
}*/
if (destroy || destroy === undefined) {

@@ -140,8 +143,54 @@ this.destroy();

},
toFront: function toFront() {
var cfg = this._cfg;
var parent = cfg.parent;
if (!parent) {
return;
}
var children = parent._cfg.children;
var el = cfg.el;
var index = children.indexOf(this);
children.splice(index, 1);
children.push(this);
if (el) {
el.parentNode.removeChild(el);
cfg.el = null;
}
},
toBack: function toBack() {
var cfg = this._cfg;
var parent = cfg.parent;
if (!parent) {
return;
}
var children = parent._cfg.children;
var el = cfg.el;
var index = children.indexOf(this);
children.splice(index, 1);
children.unshift(this);
if (el) {
var parentNode = el.parentNode;
parentNode.removeChild(el);
parentNode.insertBefore(el, parentNode.firstChild);
}
},
_beforeSetZIndex: function _beforeSetZIndex(zIndex) {
var parent = this._cfg.parent;
this._cfg.zIndex = zIndex;
if (!Util.isNil(this.get('parent'))) {
this.get('parent').sort();
if (!Util.isNil(parent)) {
parent.sort();
}
var el = this._cfg.el;
if (el) {
var children = parent._cfg.children;
var index = children.indexOf(this);
var parentNode = el.parentNode;
parentNode.removeChild(el);
if (index === children.length - 1) {
parentNode.appendChild(el);
} else {
parentNode.insertBefore(el, parentNode.childNodes[index]);
}
}
return zIndex;

@@ -148,0 +197,0 @@ },

@@ -35,2 +35,3 @@ var Util = require('../util/index');

this.set('children', []);
this.set('tobeRemoved', []);

@@ -37,0 +38,0 @@ this._beforeRenderUI();

2

lib/index.js

@@ -26,3 +26,3 @@ module.exports = {

// version, etc.
version: '3.1.0-beta.6'
version: '3.1.0-beta.7'
};

@@ -41,2 +41,3 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }

lineDash: 'stroke-dasharray',
lineDashOffset: 'stroke-dashoffset',
miterLimit: 'stroke-miterlimit',

@@ -118,4 +119,14 @@ font: 'font',

Painter.prototype._drawGroup = function _drawGroup(model) {
if (model._cfg.tobeRemoved) {
Util.each(model._cfg.tobeRemoved, function (item) {
if (item.parentNode) {
item.parentNode.removeChild(item);
}
});
model._cfg.tobeRemoved = [];
}
this._drawShape(model);
this._drawChildren(model._cfg.children);
if (model._cfg.children && model._cfg.children.length > 0) {
this._drawChildren(model._cfg.children);
}
};

@@ -320,2 +331,3 @@

}
model._cfg.attrs = {};
if (model.type === 'text') {

@@ -501,2 +513,3 @@ shape.setAttribute('paint-order', 'stroke');

var el = model._cfg.el;
var baseline = model._attrs.textBaseline || 'bottom';
if (!text) {

@@ -507,5 +520,20 @@ el.innerHTML = '';

var textArr = text.split('\n');
var textLen = textArr.length - 1;
var arr = '';
Util.each(textArr, function (segment) {
arr += '<tspan x="' + x + '" dy="1em">' + segment + '</tspan>';
Util.each(textArr, function (segment, i) {
if (i === 0) {
if (baseline === 'alphabetic') {
arr += '<tspan x="' + x + '" dy="' + -textLen + 'em">' + segment + '</tspan>';
} else if (baseline === 'top') {
arr += '<tspan x="' + x + '" dy="' + textLen + 'em">' + segment + '</tspan>';
} else if (baseline === 'middle') {
arr += '<tspan x="' + x + '" dy="0">' + segment + '</tspan>';
} else if (baseline === 'bottom') {
arr += '<tspan x="' + x + '" dy="-' + (textLen + 0.2) + 'em">' + segment + '</tspan>';
} else if (baseline === 'hanging') {
arr += '<tspan x="' + x + '" dy="-0.2em">' + segment + '</tspan>';
}
} else {
arr += '<tspan x="' + x + '" dy="1em">' + segment + '</tspan>';
}
});

@@ -512,0 +540,0 @@ el.innerHTML = arr;

{
"name": "@antv/g",
"version": "3.1.0-beta.6",
"version": "3.1.0-beta.7",
"description": "A canvas library which providing 2d draw for G2.",

@@ -5,0 +5,0 @@ "keywords": [

@@ -116,7 +116,10 @@ const Util = require('../util/index');

if (parent) {
if (el) {
parent._cfg.tobeRemoved.push(el);
}
Util.remove(parent.get('children'), this);
}
if (el) {
/* if (el) {
el.parentNode.removeChild(el);
}
}*/
if (destroy || destroy === undefined) {

@@ -138,8 +141,54 @@ this.destroy();

},
toFront() {
const cfg = this._cfg;
const parent = cfg.parent;
if (!parent) {
return;
}
const children = parent._cfg.children;
const el = cfg.el;
const index = children.indexOf(this);
children.splice(index, 1);
children.push(this);
if (el) {
el.parentNode.removeChild(el);
cfg.el = null;
}
},
toBack() {
const cfg = this._cfg;
const parent = cfg.parent;
if (!parent) {
return;
}
const children = parent._cfg.children;
const el = cfg.el;
const index = children.indexOf(this);
children.splice(index, 1);
children.unshift(this);
if (el) {
const parentNode = el.parentNode;
parentNode.removeChild(el);
parentNode.insertBefore(el, parentNode.firstChild);
}
},
_beforeSetZIndex(zIndex) {
const parent = this._cfg.parent;
this._cfg.zIndex = zIndex;
if (!Util.isNil(this.get('parent'))) {
this.get('parent').sort();
if (!Util.isNil(parent)) {
parent.sort();
}
const el = this._cfg.el;
if (el) {
const children = parent._cfg.children;
const index = children.indexOf(this);
const parentNode = el.parentNode;
parentNode.removeChild(el);
if (index === children.length - 1) {
parentNode.appendChild(el);
} else {
parentNode.insertBefore(el, parentNode.childNodes[index]);
}
}
return zIndex;

@@ -146,0 +195,0 @@ },

@@ -35,2 +35,3 @@ const Util = require('../util/index');

this.set('children', []);
this.set('tobeRemoved', []);

@@ -37,0 +38,0 @@ this._beforeRenderUI();

@@ -26,3 +26,3 @@ module.exports = {

// version, etc.
version: '3.1.0-beta.6'
version: '3.1.0-beta.7'
};

@@ -39,2 +39,3 @@ const Util = require('../../util');

lineDash: 'stroke-dasharray',
lineDashOffset: 'stroke-dashoffset',
miterLimit: 'stroke-miterlimit',

@@ -111,4 +112,14 @@ font: 'font',

_drawGroup(model) {
if (model._cfg.tobeRemoved) {
Util.each(model._cfg.tobeRemoved, item => {
if (item.parentNode) {
item.parentNode.removeChild(item);
}
});
model._cfg.tobeRemoved = [];
}
this._drawShape(model);
this._drawChildren(model._cfg.children);
if (model._cfg.children && model._cfg.children.length > 0) {
this._drawChildren(model._cfg.children);
}
}

@@ -307,2 +318,3 @@ _drawChildren(children) {

}
model._cfg.attrs = {};
if (model.type === 'text') {

@@ -483,2 +495,3 @@ shape.setAttribute('paint-order', 'stroke');

const el = model._cfg.el;
const baseline = model._attrs.textBaseline || 'bottom';
if (!text) {

@@ -489,5 +502,20 @@ el.innerHTML = '';

const textArr = text.split('\n');
const textLen = textArr.length - 1;
let arr = '';
Util.each(textArr, segment => {
arr += `<tspan x="${x}" dy="1em">${segment}</tspan>`;
Util.each(textArr, (segment, i) => {
if (i === 0) {
if (baseline === 'alphabetic') {
arr += `<tspan x="${x}" dy="${-textLen}em">${segment}</tspan>`;
} else if (baseline === 'top') {
arr += `<tspan x="${x}" dy="${textLen}em">${segment}</tspan>`;
} else if (baseline === 'middle') {
arr += `<tspan x="${x}" dy="0">${segment}</tspan>`;
} else if (baseline === 'bottom') {
arr += `<tspan x="${x}" dy="-${textLen + 0.2}em">${segment}</tspan>`;
} else if (baseline === 'hanging') {
arr += `<tspan x="${x}" dy="-0.2em">${segment}</tspan>`;
}
} else {
arr += `<tspan x="${x}" dy="1em">${segment}</tspan>`;
}
});

@@ -494,0 +522,0 @@ el.innerHTML = arr;

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 too big to display

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