mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-20 07:25:15 +02:00
Minimize number of sidebar rerenders
This commit is contained in:
+18
-7
@@ -1,5 +1,6 @@
|
||||
iD.ui.Sidebar = function(context) {
|
||||
var current;
|
||||
var inspector = iD.ui.Inspector(context),
|
||||
current;
|
||||
|
||||
function sidebar(selection) {
|
||||
var wrap = selection.append('div')
|
||||
@@ -10,10 +11,15 @@ iD.ui.Sidebar = function(context) {
|
||||
|
||||
if (!current && entity) {
|
||||
wrap.classed('inspector-hidden', false)
|
||||
.classed('inspector-hover', true)
|
||||
.call(iD.ui.Inspector(context)
|
||||
.classed('inspector-hover', true);
|
||||
|
||||
if (inspector.entityID() !== entity.id || inspector.state() !== 'hover') {
|
||||
inspector
|
||||
.state('hover')
|
||||
.entityID(entity.id));
|
||||
.entityID(entity.id);
|
||||
|
||||
wrap.call(inspector);
|
||||
}
|
||||
} else {
|
||||
wrap.classed('inspector-hidden', true);
|
||||
}
|
||||
@@ -22,10 +28,15 @@ iD.ui.Sidebar = function(context) {
|
||||
context.on('select.sidebar', function(selection) {
|
||||
if (!current && selection.length === 1) {
|
||||
wrap.classed('inspector-hidden', false)
|
||||
.classed('inspector-hover', false)
|
||||
.call(iD.ui.Inspector(context)
|
||||
.classed('inspector-hover', false);
|
||||
|
||||
if (inspector.entityID() !== selection[0] || inspector.state() !== 'select') {
|
||||
inspector
|
||||
.state('select')
|
||||
.entityID(selection[0]));
|
||||
.entityID(selection[0]);
|
||||
|
||||
wrap.call(inspector);
|
||||
}
|
||||
} else {
|
||||
wrap.classed('inspector-hidden', true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user