Only set metadata editor data when needed.

Provides a big improvement to card list scrolling performance. For #330.
This commit is contained in:
Oliver Hamlet
2014-11-16 22:58:02 +00:00
parent d8fef3a66d
commit e122902807
2 changed files with 14 additions and 7 deletions
+12 -4
View File
@@ -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. */
@@ -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);
}