From 7529b965182e3bd950dd86557defb90daf075cde Mon Sep 17 00:00:00 2001 From: wout Date: Wed, 20 Feb 2013 20:35:59 +0100 Subject: Defaulting zoom in viewbox to 1 --- src/viewbox.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src/viewbox.js') diff --git a/src/viewbox.js b/src/viewbox.js index 71e0a04..f40a76e 100644 --- a/src/viewbox.js +++ b/src/viewbox.js @@ -7,9 +7,8 @@ SVG.ViewBox = function(element) { /* clone attributes */ this.x = box.x this.y = box.y - this.width = element.node.offsetWidth - this.height = element.node.offsetHeight - this.zoom = 1 + this.width = element.node.offsetWidth || element.attr('width') + this.height = element.node.offsetHeight || element.attr('height') if (view) { /* get width and height from viewbox */ @@ -24,11 +23,13 @@ SVG.ViewBox = function(element) { this.width / width /* calculate real pixel dimensions on parent SVG.Doc element */ - if (element instanceof SVG.Doc) { - this.x = x - this.y = y - this.width = width - this.height = height - } + this.x = x + this.y = y + this.width = width + this.height = height } + + /* ensure a default zoom value */ + this.zoom = this.zoom || 1 + } \ No newline at end of file -- cgit v1.2.3