summaryrefslogtreecommitdiffstats
path: root/src/viewbox.js
diff options
context:
space:
mode:
authorwout <wout@impinc.co.uk>2013-02-20 20:35:59 +0100
committerwout <wout@impinc.co.uk>2013-02-20 20:35:59 +0100
commit7529b965182e3bd950dd86557defb90daf075cde (patch)
treec0dd845ff544be5fc4edf25abc82aacaa5d4ec43 /src/viewbox.js
parent1e183700e2582271256a279ac3e8843037e0f713 (diff)
downloadsvg.js-7529b965182e3bd950dd86557defb90daf075cde.tar.gz
svg.js-7529b965182e3bd950dd86557defb90daf075cde.zip
Defaulting zoom in viewbox to 1
Diffstat (limited to 'src/viewbox.js')
-rw-r--r--src/viewbox.js19
1 files changed, 10 insertions, 9 deletions
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