mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 01:02:58 +00:00
Persist dimensions in property to avoid reflow
This commit is contained in:
@@ -3,8 +3,15 @@ d3.selection.prototype.dimensions = function (dimensions) {
|
||||
var node = this.node();
|
||||
if (!node) return;
|
||||
|
||||
var cr = node.getBoundingClientRect();
|
||||
return [cr.width, cr.height];
|
||||
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]});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user