mirror of
https://github.com/FoggedLens/iD.git
synced 2026-03-19 09:33:32 +00:00
* One-shot development * Move jsonp to module * Tooltip -> module * Remove d3.jsonp * Fix tooltip lint * Load all libs but d3 itself with require * Add top-level brfs * Unformat intro graph
24 lines
685 B
JavaScript
24 lines
685 B
JavaScript
d3.selection.prototype.dimensions = function (dimensions) {
|
|
var refresh = (function(node) {
|
|
var cr = node.getBoundingClientRect();
|
|
var prop = [cr.width, cr.height];
|
|
this.property('__dimensions__', prop);
|
|
return prop;
|
|
}).bind(this);
|
|
|
|
var node = this.node();
|
|
|
|
if (!arguments.length) {
|
|
if (!node) return [0,0];
|
|
return this.property('__dimensions__') || refresh(node);
|
|
}
|
|
if (dimensions === null) {
|
|
if (!node) return [0,0];
|
|
return refresh(node);
|
|
}
|
|
|
|
return this
|
|
.property('__dimensions__', [dimensions[0], dimensions[1]])
|
|
.attr({width: dimensions[0], height: dimensions[1]});
|
|
};
|