mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-25 23:13:42 +00:00
18 lines
545 B
JavaScript
18 lines
545 B
JavaScript
d3.selection.prototype.dimensions = function (dimensions) {
|
|
if (!arguments.length) {
|
|
var node = this.node();
|
|
if (!node) return;
|
|
|
|
var prop = this.property('__dimensions__');
|
|
if (!prop) {
|
|
var cr = node.getBoundingClientRect();
|
|
prop = [cr.width, cr.height];
|
|
this.property('__dimensions__', prop);
|
|
}
|
|
return prop;
|
|
}
|
|
|
|
this.property('__dimensions__', [dimensions[0], dimensions[1]]);
|
|
return this.attr({width: dimensions[0], height: dimensions[1]});
|
|
};
|