zrender
Advanced tools
Comparing version 3.7.3 to 3.7.4
@@ -5,2 +5,6 @@ var _core = require("./core"); | ||
var util = require("../core/util"); | ||
var each = util.each; | ||
var zrLog = require("../core/log"); | ||
@@ -20,6 +24,2 @@ | ||
var _util = require("../core/util"); | ||
var each = _util.each; | ||
var _graphic = require("./graphic"); | ||
@@ -90,8 +90,13 @@ | ||
* @alias module:zrender/svg/Painter | ||
* @constructor | ||
* @param {HTMLElement} root 绘图容器 | ||
* @param {module:zrender/Storage} storage | ||
* @param {Object} opts | ||
*/ | ||
var SVGPainter = function (root, storage) { | ||
var SVGPainter = function (root, storage, opts) { | ||
this.root = root; | ||
this.storage = storage; | ||
this._opts = opts = util.extend({}, opts || {}); | ||
var svgRoot = createElement('svg'); | ||
@@ -102,6 +107,7 @@ svgRoot.setAttribute('xmlns', 'http://www.w3.org/2000/svg'); | ||
svgRoot.style['user-select'] = 'none'; | ||
svgRoot.style.cssText = 'position:absolute;left:0;top:0;'; | ||
this.gradientManager = new GradientManager(svgRoot); | ||
this.clipPathManager = new ClippathManager(svgRoot); | ||
var viewport = document.createElement('div'); | ||
viewport.style.cssText = 'overflow: hidden;'; | ||
viewport.style.cssText = 'overflow:hidden;position:relative'; | ||
this._svgRoot = svgRoot; | ||
@@ -111,3 +117,3 @@ this._viewport = viewport; | ||
viewport.appendChild(svgRoot); | ||
this.resize(); | ||
this.resize(opts.width, opts.height); | ||
this._visibleList = []; | ||
@@ -266,11 +272,18 @@ }; | ||
}, | ||
resize: function () { | ||
var width = this._getWidth(); | ||
resize: function (width, height) { | ||
var viewport = this._viewport; // FIXME Why ? | ||
var height = this._getHeight(); | ||
viewport.style.display = 'none'; // Save input w/h | ||
var opts = this._opts; | ||
width != null && (opts.width = width); | ||
height != null && (opts.height = height); | ||
width = this._getSize(0); | ||
height = this._getSize(1); | ||
viewport.style.display = ''; | ||
if (this._width !== width && this._height !== height) { | ||
this._width = width; | ||
this._height = height; | ||
var viewportStyle = this._viewport.style; | ||
var viewportStyle = viewport.style; | ||
viewportStyle.width = width + 'px'; | ||
@@ -284,18 +297,32 @@ viewportStyle.height = height + 'px'; | ||
}, | ||
/** | ||
* 获取绘图区域宽度 | ||
*/ | ||
getWidth: function () { | ||
return this._getWidth(); | ||
return this._width; | ||
}, | ||
/** | ||
* 获取绘图区域高度 | ||
*/ | ||
getHeight: function () { | ||
return this._getHeight(); | ||
return this._height; | ||
}, | ||
_getWidth: function () { | ||
var root = this.root; | ||
_getSize: function (whIdx) { | ||
var opts = this._opts; | ||
var wh = ['width', 'height'][whIdx]; | ||
var cwh = ['clientWidth', 'clientHeight'][whIdx]; | ||
var plt = ['paddingLeft', 'paddingTop'][whIdx]; | ||
var prb = ['paddingRight', 'paddingBottom'][whIdx]; | ||
if (opts[wh] != null && opts[wh] !== 'auto') { | ||
return parseFloat(opts[wh]); | ||
} | ||
var root = this.root; // IE8 does not support getComputedStyle, but it use VML. | ||
var stl = document.defaultView.getComputedStyle(root); | ||
return (root.clientWidth || parseInt10(stl.width)) - parseInt10(stl.paddingLeft) - parseInt10(stl.paddingRight) | 0; | ||
return (root[cwh] || parseInt10(stl[wh]) || parseInt10(root.style[wh])) - (parseInt10(stl[plt]) || 0) - (parseInt10(stl[prb]) || 0) | 0; | ||
}, | ||
_getHeight: function () { | ||
var root = this.root; | ||
var stl = document.defaultView.getComputedStyle(root); | ||
return (root.clientHeight || parseInt10(stl.height)) - parseInt10(stl.paddingTop) - parseInt10(stl.paddingBottom) | 0; | ||
}, | ||
dispose: function () { | ||
@@ -302,0 +329,0 @@ this.root.innerHTML = ''; |
@@ -36,3 +36,3 @@ var guid = require("./core/guid"); | ||
var version = '3.7.3'; | ||
var version = '3.7.4'; | ||
/** | ||
@@ -39,0 +39,0 @@ * Initializing a zrender instance |
{ | ||
"name": "zrender", | ||
"version": "3.7.3", | ||
"version": "3.7.4", | ||
"description": "A lightweight canvas library.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -7,2 +7,3 @@ /** | ||
import {createElement} from './core'; | ||
import * as util from '../core/util'; | ||
import zrLog from '../core/log'; | ||
@@ -83,8 +84,12 @@ import Path from '../graphic/Path'; | ||
* @alias module:zrender/svg/Painter | ||
* @constructor | ||
* @param {HTMLElement} root 绘图容器 | ||
* @param {module:zrender/Storage} storage | ||
* @param {Object} opts | ||
*/ | ||
var SVGPainter = function (root, storage) { | ||
var SVGPainter = function (root, storage, opts) { | ||
this.root = root; | ||
this.storage = storage; | ||
this._opts = opts = util.extend({}, opts || {}); | ||
@@ -96,2 +101,3 @@ var svgRoot = createElement('svg'); | ||
svgRoot.style['user-select'] = 'none'; | ||
svgRoot.style.cssText = 'position:absolute;left:0;top:0;'; | ||
@@ -102,3 +108,3 @@ this.gradientManager = new GradientManager(svgRoot); | ||
var viewport = document.createElement('div'); | ||
viewport.style.cssText = 'overflow: hidden;'; | ||
viewport.style.cssText = 'overflow:hidden;position:relative'; | ||
@@ -111,3 +117,3 @@ this._svgRoot = svgRoot; | ||
this.resize(); | ||
this.resize(opts.width, opts.height); | ||
@@ -288,6 +294,17 @@ this._visibleList = []; | ||
resize: function () { | ||
var width = this._getWidth(); | ||
var height = this._getHeight(); | ||
resize: function (width, height) { | ||
var viewport = this._viewport; | ||
// FIXME Why ? | ||
viewport.style.display = 'none'; | ||
// Save input w/h | ||
var opts = this._opts; | ||
width != null && (opts.width = width); | ||
height != null && (opts.height = height); | ||
width = this._getSize(0); | ||
height = this._getSize(1); | ||
viewport.style.display = ''; | ||
if (this._width !== width && this._height !== height) { | ||
@@ -297,3 +314,3 @@ this._width = width; | ||
var viewportStyle = this._viewport.style; | ||
var viewportStyle = viewport.style; | ||
viewportStyle.width = width + 'px'; | ||
@@ -309,26 +326,36 @@ viewportStyle.height = height + 'px'; | ||
/** | ||
* 获取绘图区域宽度 | ||
*/ | ||
getWidth: function () { | ||
return this._getWidth(); | ||
return this._width; | ||
}, | ||
/** | ||
* 获取绘图区域高度 | ||
*/ | ||
getHeight: function () { | ||
return this._getHeight(); | ||
return this._height; | ||
}, | ||
_getWidth: function () { | ||
var root = this.root; | ||
var stl = document.defaultView.getComputedStyle(root); | ||
_getSize: function (whIdx) { | ||
var opts = this._opts; | ||
var wh = ['width', 'height'][whIdx]; | ||
var cwh = ['clientWidth', 'clientHeight'][whIdx]; | ||
var plt = ['paddingLeft', 'paddingTop'][whIdx]; | ||
var prb = ['paddingRight', 'paddingBottom'][whIdx]; | ||
return ((root.clientWidth || parseInt10(stl.width)) | ||
- parseInt10(stl.paddingLeft) | ||
- parseInt10(stl.paddingRight)) | 0; | ||
}, | ||
if (opts[wh] != null && opts[wh] !== 'auto') { | ||
return parseFloat(opts[wh]); | ||
} | ||
_getHeight: function () { | ||
var root = this.root; | ||
// IE8 does not support getComputedStyle, but it use VML. | ||
var stl = document.defaultView.getComputedStyle(root); | ||
return ((root.clientHeight || parseInt10(stl.height)) | ||
- parseInt10(stl.paddingTop) | ||
- parseInt10(stl.paddingBottom)) | 0; | ||
return ( | ||
(root[cwh] || parseInt10(stl[wh]) || parseInt10(root.style[wh])) | ||
- (parseInt10(stl[plt]) || 0) | ||
- (parseInt10(stl[prb]) || 0) | ||
) | 0; | ||
}, | ||
@@ -335,0 +362,0 @@ |
@@ -31,3 +31,3 @@ /*! | ||
*/ | ||
export var version = '3.7.3'; | ||
export var version = '3.7.4'; | ||
@@ -34,0 +34,0 @@ /** |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 2 instances in 1 package
3002766
208
60557
8