Socket
Socket
Sign inDemoInstall

@antv/g

Package Overview
Dependencies
Maintainers
7
Versions
349
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.3.4 to 3.3.5

18

lib/canvas.js

@@ -196,13 +196,18 @@ var Util = require('./util/index');

_scale: function _scale() {
var pixelRatio = this.get('pixelRatio');
this.scale(pixelRatio, pixelRatio);
if (this._cfg.renderType !== 'svg') {
var pixelRatio = this.get('pixelRatio');
this.scale(pixelRatio, pixelRatio);
}
},
_setGlobalParam: function _setGlobalParam() {
var pixelRatio = this.get('pixelRatio');
var renderType = this.get('renderer') || 'canvas';
if (!pixelRatio) {
if (renderType === 'svg') {
this.set('pixelRatio', 1);
} else if (!this.get('pixelRatio')) {
this.set('pixelRatio', Util.getRatio());
}
var renderer = renderers[this.get('renderer') || 'canvas'];
this._cfg.renderType = renderType;
var renderer = renderers[renderType];
this._cfg.renderer = renderer;

@@ -302,2 +307,5 @@ this._cfg.canvas = this;

},
getRenderer: function getRenderer() {
return this._cfg.renderType;
},
_drawSync: function _drawSync() {

@@ -304,0 +312,0 @@ this._cfg.painter.drawSync(this);

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

// version, etc.
version: '3.3.4'
version: '3.3.5'
};

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

var regexPR = /^p\s*\(\s*([axyn])\s*\)\s*(.*)/i;
var regexColorStop = /[\d.]+:(#[^\s]+|[^\)]+\))/ig;
var numColorCache = {};
var regexColorStop = /[\d.]+:(#[^\s]+|[^\)]+\))/ig; // const numColorCache = {};

@@ -202,20 +201,18 @@ function addStop(steps, gradient) {

}
},
numberToColor: function numberToColor(num) {
}
/* ,
numberToColor(num) {
// 增加缓存
var color = numColorCache[num];
let color = numColorCache[num];
if (!color) {
var str = num.toString(16);
for (var i = str.length; i < 6; i++) {
let str = num.toString(16);
for (let i = str.length; i < 6; i++) {
str = '0' + str;
}
color = '#' + str;
numColorCache[num] = color;
}
return color;
}*/
return color;
}
};

@@ -108,5 +108,3 @@ var Util = require('../../util');

try {
model.resetMatrix();
self._drawGroup(model, false);
self._drawChildren(model);
} catch (ev) {

@@ -130,6 +128,6 @@ // 绘制时异常,中断重绘

_proto.drawSync = function drawSync(model) {
this._drawChildren(model, false);
this._drawChildren(model);
};
_proto._drawGroup = function _drawGroup(model, redraw) {
_proto._drawGroup = function _drawGroup(model, index) {
var cfg = model._cfg;

@@ -140,13 +138,3 @@

}
/**
* FIXME redraw: 为了使元素置顶的临时解决方案
* 如果直接将dom元素重排可以解决部分问题。但是如果重排后的group中有新增的shape,置顶效果就没有了
* 所以只能删除原有节点,新增节点以及所有子节点。这时候哪怕shape有el,也需要判断一下是否需要重绘
*/
if (!cfg.el && cfg.attrs) {
redraw = true;
}
if (cfg.tobeRemoved) {

@@ -161,10 +149,10 @@ Util.each(cfg.tobeRemoved, function (item) {

this._drawShape(model, redraw);
this._drawShape(model, index);
if (cfg.children && cfg.children.length > 0) {
this._drawChildren(model, redraw);
this._drawChildren(model);
}
};
_proto._drawChildren = function _drawChildren(parent, redraw) {
_proto._drawChildren = function _drawChildren(parent) {
var self = this;

@@ -178,11 +166,2 @@ var children = parent._cfg.children;

if (parent._cfg.el && !redraw) {
// FIXME 这边是为了解决一个group中有元素已经生成el,还有一些没生成el时,没生成el的置底效果不work
var childLen = parent._cfg.el.childNodes.length + 1;
if (childLen !== 0 && childLen !== children.length) {
redraw = true;
}
}
for (var i = 0; i < children.length; i++) {

@@ -192,5 +171,5 @@ shape = children[i];

if (shape.isGroup) {
self._drawGroup(shape, redraw);
self._drawGroup(shape, i);
} else {
self._drawShape(shape, redraw);
self._drawShape(shape, i);
}

@@ -200,3 +179,3 @@ }

_proto._drawShape = function _drawShape(model, redraw) {
_proto._drawShape = function _drawShape(model, index) {
var self = this;

@@ -213,8 +192,2 @@ var attrs = model._attrs;

return;
} // 重绘节点
if (redraw && el) {
el.parentNode && el.parentNode.removeChild(el);
el = null;
} // 新增节点

@@ -224,3 +197,3 @@

if (!el && cfg.parent) {
self._createDom(model);
self._createDom(model, index);

@@ -421,5 +394,7 @@ self._updateShape(model);

_proto._createDom = function _createDom(model) {
_proto._createDom = function _createDom(model, index) {
var type = SHAPE_TO_TAGS[model.type];
var attrs = model._attrs;
var parent = model._cfg.parent;
var parentNode = parent._cfg.el;

@@ -433,4 +408,18 @@ if (!type) {

if (model._cfg.parent) {
model._cfg.parent.get('el').appendChild(shape);
if (parent) {
if (typeof index === 'undefined') {
parentNode.appendChild(shape);
} else {
var childNodes = parent._cfg.el.childNodes; // svg下天然有defs作为子节点,svg下子元素index需要+1
if (parentNode.tagName === 'svg') {
index += 1;
}
if (childNodes.length <= index) {
parentNode.appendChild(shape);
} else {
parentNode.insertBefore(shape, childNodes[index]);
}
}
}

@@ -437,0 +426,0 @@

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

var regexDot = /[^\s\,]+/ig;
var numColorCache = {};
module.exports = {

@@ -68,20 +67,3 @@ parseRadius: function parseRadius(radius) {

}
},
numberToColor: function numberToColor(num) {
// 增加缓存
var color = numColorCache[num];
if (!color) {
var str = num.toString(16);
for (var i = str.length; i < 6; i++) {
str = '0' + str;
}
color = '#' + str;
numColorCache[num] = color;
}
return color;
}
};
{
"name": "@antv/g",
"version": "3.3.4",
"version": "3.3.5",
"description": "A canvas library which providing 2d draw for G2.",

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

@@ -180,11 +180,16 @@ const Util = require('./util/index');

_scale() {
const pixelRatio = this.get('pixelRatio');
this.scale(pixelRatio, pixelRatio);
if (this._cfg.renderType !== 'svg') {
const pixelRatio = this.get('pixelRatio');
this.scale(pixelRatio, pixelRatio);
}
},
_setGlobalParam() {
const pixelRatio = this.get('pixelRatio');
if (!pixelRatio) {
const renderType = this.get('renderer') || 'canvas';
if (renderType === 'svg') {
this.set('pixelRatio', 1);
} else if (!this.get('pixelRatio')) {
this.set('pixelRatio', Util.getRatio());
}
const renderer = renderers[this.get('renderer') || 'canvas'];
this._cfg.renderType = renderType;
const renderer = renderers[renderType];
this._cfg.renderer = renderer;

@@ -281,2 +286,5 @@ this._cfg.canvas = this;

},
getRenderer() {
return this._cfg.renderType;
},
_drawSync() {

@@ -283,0 +291,0 @@ this._cfg.painter.drawSync(this);

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

// version, etc.
version: '3.3.4'
version: '3.3.5'
};

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

const regexColorStop = /[\d.]+:(#[^\s]+|[^\)]+\))/ig;
const numColorCache = {};
// const numColorCache = {};

@@ -189,3 +189,4 @@ function addStop(steps, gradient) {

}
},
}
/* ,
numberToColor(num) {

@@ -203,4 +204,4 @@ // 增加缓存

return color;
}
}*/
};

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

try {
model.resetMatrix();
self._drawGroup(model, false);
self._drawChildren(model);
} catch (ev) { // 绘制时异常,中断重绘

@@ -116,5 +115,5 @@ console.warn('error in draw canvas, detail as:');

drawSync(model) {
this._drawChildren(model, false);
this._drawChildren(model);
}
_drawGroup(model, redraw) {
_drawGroup(model, index) {
const cfg = model._cfg;

@@ -124,10 +123,2 @@ if (cfg.removed || cfg.destroyed) {

}
/**
* FIXME redraw: 为了使元素置顶的临时解决方案
* 如果直接将dom元素重排可以解决部分问题。但是如果重排后的group中有新增的shape,置顶效果就没有了
* 所以只能删除原有节点,新增节点以及所有子节点。这时候哪怕shape有el,也需要判断一下是否需要重绘
*/
if (!cfg.el && cfg.attrs) {
redraw = true;
}
if (cfg.tobeRemoved) {

@@ -141,8 +132,8 @@ Util.each(cfg.tobeRemoved, item => {

}
this._drawShape(model, redraw);
this._drawShape(model, index);
if (cfg.children && cfg.children.length > 0) {
this._drawChildren(model, redraw);
this._drawChildren(model);
}
}
_drawChildren(parent, redraw) {
_drawChildren(parent) {
const self = this;

@@ -155,20 +146,12 @@ const children = parent._cfg.children;

}
if (parent._cfg.el && !redraw) {
// FIXME 这边是为了解决一个group中有元素已经生成el,还有一些没生成el时,没生成el的置底效果不work
const childLen = parent._cfg.el.childNodes.length + 1;
if (childLen !== 0 && childLen !== children.length) {
redraw = true;
}
}
for (let i = 0; i < children.length; i++) {
shape = children[i];
if (shape.isGroup) {
self._drawGroup(shape, redraw);
self._drawGroup(shape, i);
} else {
self._drawShape(shape, redraw);
self._drawShape(shape, i);
}
}
}
_drawShape(model, redraw) {
_drawShape(model, index) {
const self = this;

@@ -186,11 +169,5 @@ const attrs = model._attrs;

// 重绘节点
if (redraw && el) {
el.parentNode && el.parentNode.removeChild(el);
el = null;
}
// 新增节点
if (!el && cfg.parent) {
self._createDom(model);
self._createDom(model, index);
self._updateShape(model);

@@ -349,5 +326,7 @@ }

}
_createDom(model) {
_createDom(model, index) {
const type = SHAPE_TO_TAGS[model.type];
const attrs = model._attrs;
const parent = model._cfg.parent;
const parentNode = parent._cfg.el;
if (!type) {

@@ -358,4 +337,17 @@ throw new Error('the type' + model.type + 'is not supported by svg');

model._cfg.el = shape;
if (model._cfg.parent) {
model._cfg.parent.get('el').appendChild(shape);
if (parent) {
if (typeof index === 'undefined') {
parentNode.appendChild(shape);
} else {
const childNodes = parent._cfg.el.childNodes;
// svg下天然有defs作为子节点,svg下子元素index需要+1
if (parentNode.tagName === 'svg') {
index += 1;
}
if (childNodes.length <= index) {
parentNode.appendChild(shape);
} else {
parentNode.insertBefore(shape, childNodes[index]);
}
}
}

@@ -362,0 +354,0 @@ model._cfg.attrs = {};

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

const regexDot = /[^\s\,]+/ig;
const numColorCache = {};

@@ -64,16 +63,3 @@ module.exports = {

}
},
numberToColor(num) {
// 增加缓存
let color = numColorCache[num];
if (!color) {
let str = num.toString(16);
for (let i = str.length; i < 6; i++) {
str = '0' + str;
}
color = '#' + str;
numColorCache[num] = color;
}
return color;
}
};

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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