From 87e3b928d038be757ba0a7c7076af9dc4a18e1d0 Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Wed, 3 Apr 2019 23:26:26 -0400 Subject: [PATCH] Reduce drawing during history changes (closes #6086) --- modules/renderer/map.js | 8 +++----- modules/ui/entity_editor.js | 3 ++- modules/ui/selection_list.js | 12 +++++++----- modules/ui/tools/save.js | 9 ++++++--- modules/ui/tools/undo_redo.js | 4 +++- 5 files changed, 21 insertions(+), 15 deletions(-) diff --git a/modules/renderer/map.js b/modules/renderer/map.js index 64f360483..7b1ec28b6 100644 --- a/modules/renderer/map.js +++ b/modules/renderer/map.js @@ -263,7 +263,7 @@ export function rendererMap(context) { } - function drawVector(difference, extent) { + function drawEditable(difference, extent) { var mode = context.mode(); var graph = context.graph(); var features = context.features(); @@ -576,15 +576,13 @@ export function rendererMap(context) { if (!difference) { supersurface.call(context.background()); + wrapper.call(drawLayers); } - wrapper - .call(drawLayers); - // OSM if (map.editable()) { context.loadTiles(projection); - drawVector(difference, extent); + drawEditable(difference, extent); } else { editOff(); } diff --git a/modules/ui/entity_editor.js b/modules/ui/entity_editor.js index 1a58a27d2..6690297c0 100644 --- a/modules/ui/entity_editor.js +++ b/modules/ui/entity_editor.js @@ -239,8 +239,9 @@ export function uiEntityEditor(context) { .on('change.entity-editor', historyChanged); - function historyChanged() { + function historyChanged(difference) { if (_state === 'hide') return; + if (!difference || !difference.didChange.properties) return; var entity = context.hasEntity(_entityID); var graph = context.graph(); diff --git a/modules/ui/selection_list.js b/modules/ui/selection_list.js index 0380f856b..031b75025 100644 --- a/modules/ui/selection_list.js +++ b/modules/ui/selection_list.js @@ -1,7 +1,4 @@ -import { - event as d3_event, - select as d3_select -} from 'd3-selection'; +import { event as d3_event, select as d3_select } from 'd3-selection'; import { t } from '../util/locale'; import { modeSelect } from '../modes'; @@ -46,7 +43,12 @@ export function uiSelectionList(context, selectedIDs) { .append('div') .attr('class', 'feature-list cf'); - context.history().on('change.selection-list', drawList); + + context.history() + .on('change.selectionList', function(difference) { + if (difference) drawList(); + }); + drawList(); diff --git a/modules/ui/tools/save.js b/modules/ui/tools/save.js index f84bbf5c6..89fe4ea5b 100644 --- a/modules/ui/tools/save.js +++ b/modules/ui/tools/save.js @@ -16,8 +16,8 @@ export function uiToolSave(context) { label: t('save.title') }; - var button = null, - tooltipBehavior = null; + var button = null; + var tooltipBehavior = null; var history = context.history(); var key = uiCmd('⌘S'); var _numChanges = 0; @@ -102,8 +102,11 @@ export function uiToolSave(context) { context.keybinding() .on(key, save, true); + context.history() - .on('change.save', updateCount); + .on('change.save', function(difference) { + if (difference) updateCount(); + }); context .on('enter.save', function() { diff --git a/modules/ui/tools/undo_redo.js b/modules/ui/tools/undo_redo.js index 3e61b8767..a46a9c7da 100644 --- a/modules/ui/tools/undo_redo.js +++ b/modules/ui/tools/undo_redo.js @@ -81,7 +81,9 @@ export function uiToolUndoRedo(context) { .on('drawn.undo_redo', debouncedUpdate); context.history() - .on('change.undo_redo', update); + .on('change.undo_redo', function(difference) { + if (difference) update(); + }); context .on('enter.undo_redo', update);