What is the correct way to get the size of a paper object using SnapSVG once it is created?
My HTML is as follows:
<div id="myContainer" style="width: 900px; height: 100px" />
And then the Javascript code:
function initViewer(elementId) { var element, elementRef, snap; elementRef = '#' + elementId; element = $(elementRef); element.append('<svg style="width: ' + element.width() + 'px; height: ' + element.height() + 'px; border: solid 1px black;"/>'); snap = Snap(elementRef + ' svg'); console.log(snap.getBBox()); }
What I am observing here is a bounding box that has a "0" for all attributes, so I cannot rely on the bounding box values ββhere. Are there any ways to do this without going to the parent element?
What I essentially want is the width and height of the SVG, so I can draw shapes of the appropriate size for the view.
JS Fiddle illustrating the problem: https://jsfiddle.net/ajmas/kdnx2eyf/1/
Andre M Dec 22 '15 at 20:36 2015-12-22 20:36
source share