Files
iD/js/lib/d3.dimensions.js
Bryan Housel 0210d69177 Use getBoundingClientRect for dimensions instead of offsetHeight/offsetWidth
`offsetHeight`/`offsetWidth` does not work for SVG Elements except in Chrome
and this support is being removed from Chrome soon:

>'SVGElement.offsetWidth' is deprecated and will be removed in M50, around
April 2016. See https://www.chromestatus.com/features/5724912467574784 for
more details.
2016-02-10 17:08:11 -05:00

11 lines
312 B
JavaScript

d3.selection.prototype.dimensions = function (dimensions) {
if (!arguments.length) {
var node = this.node();
if (!node) return;
var cr = node.getBoundingClientRect();
return [cr.width, cr.height];
}
return this.attr({width: dimensions[0], height: dimensions[1]});
};