From e12290280735ffa1d6986f7c3e8b06c2e2459db4 Mon Sep 17 00:00:00 2001 From: Oliver Hamlet Date: Sun, 16 Nov 2014 22:58:02 +0000 Subject: [PATCH] Only set metadata editor data when needed. Provides a big improvement to card list scrolling performance. For #330. --- resources/report/html/loot-plugin-card.html | 16 ++++++++++++---- resources/report/html/loot-plugin-editor.html | 5 ++--- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/resources/report/html/loot-plugin-card.html b/resources/report/html/loot-plugin-card.html index 9aadeeca..c03f6d79 100644 --- a/resources/report/html/loot-plugin-card.html +++ b/resources/report/html/loot-plugin-card.html @@ -196,11 +196,14 @@ loot-clear-metadata }, dataChanged: function(oldValue, newValue) { - /* Share the data with the editor. */ - this.shadowRoot.getElementById('editor').data = this.data; if (newValue != undefined) { + if (newValue.isEditorOpen) { + /* Share the data with the editor. */ + this.shadowRoot.getElementById('editor').data = newValue; + } + /* Set the card flip state. */ - if (this.classList.contains('flip') != this.data.isEditorOpen) { + if (this.classList.contains('flip') != newValue.isEditorOpen) { /* Temporarily speed up the flip effect, as otherwise fast scrolling lets the user see the end of it. */ this.classList.add('fastflip'); @@ -213,7 +216,7 @@ loot-clear-metadata this.onMessagesChange(); /* Also set highlight if the conflict filter is active. */ - this.classList.toggle('highlight', this.data.isConflictFilterChecked); + this.classList.toggle('highlight', newValue.isConflictFilterChecked); } }, @@ -277,6 +280,11 @@ loot-clear-metadata onShowEditor: function(evt) { var card = evt.target.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentNode.host; + /* If the editor hasn't already been opened, its data is not yet set, so do that now. */ + if (!card.data.isEditorOpen && !card.data.editor) { + card.shadowRoot.getElementById('editor').data = card.data; + } + card.data.isEditorOpen = true; /* Fire an open event, so that the UI can enter edit mode. */ diff --git a/resources/report/html/loot-plugin-editor.html b/resources/report/html/loot-plugin-editor.html index 89a9904d..d3c2c67d 100644 --- a/resources/report/html/loot-plugin-editor.html +++ b/resources/report/html/loot-plugin-editor.html @@ -256,9 +256,8 @@ loot-editor-close }, dataChanged: function(oldValue, newValue) { - /* Record the current editor data. This is only strictly necessary - if the editor is currently open, but editor state isn't yet recorded. */ - if (oldValue) { + /* Record the current editor data if the editor is open. */ + if (oldValue && this.data.isEditorOpen) { oldValue.editor = this.readFromEditor(oldValue); }