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.5 to 3.1.0-beta.6

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

10

lib/canvas.js

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

init: function init() {
var _this = this;
Canvas.superclass.init.call(this);

@@ -80,7 +78,2 @@ this._setGlobalParam();

}
this.draw = Util.throttle(function () {
_this.emit('beforedraw');
_this._cfg.painter.draw(_this);
_this.emit('afterdraw');
}, 16);
},

@@ -272,2 +265,5 @@ getEmitter: function getEmitter(element, event) {

},
draw: function draw() {
this._cfg.painter.draw(this);
},
getShape: function getShape(x, y, e) {

@@ -274,0 +270,0 @@ if (arguments.length === 3 && this._cfg.renderer.getShape) {

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

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

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

Painter.prototype.draw = function draw(model) {
this._drawGroup(model);
// const self = this;
// function drawInner() {
// self.animateHandler = Util.requestAnimationFrame(() => {
// self.animateHandler = undefined;
// if (self.toDraw) {
// drawInner();
// }
// });
// self.beforeDraw();
// try {
// self._drawGroup(model);
// } catch (ev) { // 绘制时异常,中断重绘
// console.warn('error in draw canvas, detail as:');
// console.warn(ev);
// self.toDraw = false;
// }
// self.toDraw = false;
// }
// if (self.animateHandler) {
// self.toDraw = true;
// } else {
// drawInner();
// }
var self = this;
function drawInner() {
self.animateHandler = Util.requestAnimationFrame(function () {
self.animateHandler = undefined;
if (self.toDraw) {
drawInner();
}
});
self.beforeDraw();
try {
self._drawGroup(model);
} catch (ev) {
// 绘制时异常,中断重绘
console.warn('error in draw canvas, detail as:');
console.warn(ev);
self.toDraw = false;
}
self.toDraw = false;
}
if (self.animateHandler) {
self.toDraw = true;
} else {
drawInner();
}
};

@@ -57,0 +57,0 @@

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

Painter.prototype.draw = function draw(model) {
this._drawChildren(model._cfg.children);
var self = this;
function drawInner() {
self.animateHandler = Util.requestAnimationFrame(function () {
self.animateHandler = undefined;
if (self.toDraw) {
drawInner();
}
});
try {
self._drawChildren(model._cfg.children);
} catch (ev) {
// 绘制时异常,中断重绘
console.warn('error in draw canvas, detail as:');
console.warn(ev);
self.toDraw = false;
}
self.toDraw = false;
}
if (self.animateHandler) {
self.toDraw = true;
} else {
drawInner();
}
};

@@ -94,0 +116,0 @@

@@ -28,60 +28,3 @@ var Util = require('@antv/util/lib');

mod: Util.mod,
clamp: Util.clamp,
/**
* @param {Function} fn 实际要执行的函数
* @param {Number} threshhold 执行间隔,单位是毫秒(ms)
* @return {Function} 返回一个“节流”函数
*/
throttle: function throttle(fn, threshhold) {
// 记录上次执行的时间
var last = void 0;
// 定时器
var timer = void 0;
// 默认间隔为 250ms
threshhold || (threshhold = 250);
// 返回的函数,每过 threshhold 毫秒就执行一次 fn 函数
return function () {
// 保存函数调用时的上下文和参数,传递给 fn
var context = this;
var args = arguments;
var now = +new Date();
// 如果距离上次执行 fn 函数的时间小于 threshhold,那么就放弃
// 执行 fn,并重新计时
if (last && now < last + threshhold) {
clearTimeout(timer);
// 保证在当前时间区间结束后,再执行一次 fn
timer = setTimeout(function () {
last = now;
fn.apply(context, args);
}, threshhold);
// 在时间区间的最开始和到达指定间隔的时候执行一次 fn
} else {
last = now;
fn.apply(context, args);
}
};
},
/**
* @param {Function} fn 实际要执行的函数
* @param {Number} threshhold 延迟时间,单位是毫秒(ms)
* @return {Function} 返回一个“防反跳”了的函数
*/
debounce: function debounce(fn, threshhold) {
// 定时器,用来 setTimeout
var timer = void 0;
// 返回一个函数,这个函数会在一个时间区间结束后的 threshhold 毫秒时执行 fn 函数
return function () {
// 保存函数调用时的上下文和参数,传递给 fn
var context = this;
var args = arguments;
// 每次这个返回的函数被调用,就清除定时器,以保证不执行 fn
clearTimeout(timer);
// 当返回的函数被最后一次调用后(也就是用户停止了某个连续的操作),
// 再过 threshhold 毫秒就执行 fn
timer = setTimeout(function () {
fn.apply(context, args);
}, threshhold);
};
}
clamp: Util.clamp
};
{
"name": "@antv/g",
"version": "3.1.0-beta.5",
"version": "3.1.0-beta.6",
"description": "A canvas library which providing 2d draw for G2.",

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

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

}
this.draw = Util.throttle(() => {
this.emit('beforedraw');
this._cfg.painter.draw(this);
this.emit('afterdraw');
}, 16);
},

@@ -278,2 +273,5 @@ getEmitter(element, event) {

},
draw() {
this._cfg.painter.draw(this);
},
getShape(x, y, e) {

@@ -280,0 +278,0 @@ if (arguments.length === 3 && this._cfg.renderer.getShape) {

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

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

@@ -42,26 +42,25 @@ const Util = require('../../util');

draw(model) {
this._drawGroup(model);
// const self = this;
// function drawInner() {
// self.animateHandler = Util.requestAnimationFrame(() => {
// self.animateHandler = undefined;
// if (self.toDraw) {
// drawInner();
// }
// });
// self.beforeDraw();
// try {
// self._drawGroup(model);
// } catch (ev) { // 绘制时异常,中断重绘
// console.warn('error in draw canvas, detail as:');
// console.warn(ev);
// self.toDraw = false;
// }
// self.toDraw = false;
// }
// if (self.animateHandler) {
// self.toDraw = true;
// } else {
// drawInner();
// }
const self = this;
function drawInner() {
self.animateHandler = Util.requestAnimationFrame(() => {
self.animateHandler = undefined;
if (self.toDraw) {
drawInner();
}
});
self.beforeDraw();
try {
self._drawGroup(model);
} catch (ev) { // 绘制时异常,中断重绘
console.warn('error in draw canvas, detail as:');
console.warn(ev);
self.toDraw = false;
}
self.toDraw = false;
}
if (self.animateHandler) {
self.toDraw = true;
} else {
drawInner();
}
}

@@ -68,0 +67,0 @@ _drawGroup(group) {

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

draw(model) {
this._drawChildren(model._cfg.children);
const self = this;
function drawInner() {
self.animateHandler = Util.requestAnimationFrame(() => {
self.animateHandler = undefined;
if (self.toDraw) {
drawInner();
}
});
try {
self._drawChildren(model._cfg.children);
} catch (ev) { // 绘制时异常,中断重绘
console.warn('error in draw canvas, detail as:');
console.warn(ev);
self.toDraw = false;
}
self.toDraw = false;
}
if (self.animateHandler) {
self.toDraw = true;
} else {
drawInner();
}
}

@@ -89,0 +110,0 @@ _drawGroup(model) {

@@ -28,59 +28,3 @@ const Util = require('@antv/util/lib');

mod: Util.mod,
clamp: Util.clamp,
/**
* @param {Function} fn 实际要执行的函数
* @param {Number} threshhold 执行间隔,单位是毫秒(ms)
* @return {Function} 返回一个“节流”函数
*/
throttle(fn, threshhold) {
// 记录上次执行的时间
let last;
// 定时器
let timer;
// 默认间隔为 250ms
threshhold || (threshhold = 250);
// 返回的函数,每过 threshhold 毫秒就执行一次 fn 函数
return function() {
// 保存函数调用时的上下文和参数,传递给 fn
const context = this;
const args = arguments;
const now = +new Date();
// 如果距离上次执行 fn 函数的时间小于 threshhold,那么就放弃
// 执行 fn,并重新计时
if (last && now < last + threshhold) {
clearTimeout(timer);
// 保证在当前时间区间结束后,再执行一次 fn
timer = setTimeout(function() {
last = now;
fn.apply(context, args);
}, threshhold);
// 在时间区间的最开始和到达指定间隔的时候执行一次 fn
} else {
last = now;
fn.apply(context, args);
}
};
},
/**
* @param {Function} fn 实际要执行的函数
* @param {Number} threshhold 延迟时间,单位是毫秒(ms)
* @return {Function} 返回一个“防反跳”了的函数
*/
debounce(fn, threshhold) {
// 定时器,用来 setTimeout
let timer;
// 返回一个函数,这个函数会在一个时间区间结束后的 threshhold 毫秒时执行 fn 函数
return function() {
// 保存函数调用时的上下文和参数,传递给 fn
const context = this;
const args = arguments;
// 每次这个返回的函数被调用,就清除定时器,以保证不执行 fn
clearTimeout(timer);
// 当返回的函数被最后一次调用后(也就是用户停止了某个连续的操作),
// 再过 threshhold 毫秒就执行 fn
timer = setTimeout(function() {
fn.apply(context, args);
}, threshhold);
};
}
clamp: Util.clamp
};

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