diff options
Diffstat (limited to 'dist/svg.js')
-rw-r--r-- | dist/svg.js | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/dist/svg.js b/dist/svg.js index 6e75c95..3344907 100644 --- a/dist/svg.js +++ b/dist/svg.js @@ -1,4 +1,4 @@ -/* svg.js v0.33-5-gf8236f9 - svg regex default color array number viewbox bbox rbox element parent container fx event defs group arrange mask clip gradient doc shape use rect ellipse line poly path image text textpath nested sugar set memory loader - svgjs.com/license */ +/* svg.js v0.33-6-gc967856 - svg regex default color array number viewbox bbox rbox element parent container fx event defs group arrange mask clip gradient doc shape use rect ellipse line poly path image text textpath nested sugar set memory loader - svgjs.com/license */ ;(function() { this.SVG = function(element) { @@ -529,14 +529,31 @@ SVG.ViewBox = function(element) { var x, y, width, height + , wm = 1 /* width multiplier */ + , hm = 1 /* height multiplier */ , box = element.bbox() , view = (element.attr('viewBox') || '').match(/-?[\d\.]+/g) + + /* get dimensions of current node */ + width = new SVG.Number(element.width()) + height = new SVG.Number(element.height()) + + /* find nearest non-percentual dimensions */ + while (width.unit == '%') { + wm *= width.value + width = new SVG.Number(element instanceof SVG.Doc ? element.parent.offsetWidth : element.width()) + } + while (height.unit == '%') { + hm *= height.value + height = new SVG.Number(element instanceof SVG.Doc ? element.parent.offsetHeight : element.height()) + } - /* clone attributes */ + /* ensure defaults */ this.x = box.x this.y = box.y - this.width = element.node.clientWidth || element.attr('width') - this.height = element.node.clientHeight || element.attr('height') + this.width = width * wm + this.height = height * hm + this.zoom = 1 if (view) { /* get width and height from viewbox */ @@ -555,11 +572,9 @@ this.y = y this.width = width this.height = height + } - /* ensure a default zoom value */ - this.zoom = this.zoom || 1 - } // |