mirror of
https://github.com/FoggedLens/iD.git
synced 2026-03-21 18:43:23 +00:00
`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.
11 lines
312 B
JavaScript
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]});
|
|
};
|