From dc846aa7dda7a91c15837838405984db9d50572a Mon Sep 17 00:00:00 2001 From: tophf Date: Tue, 27 Jun 2017 23:00:24 +0300 Subject: [PATCH] code cosmetics: animateElement() 'highlight' by default --- backup/fileSaveLoad.js | 2 +- dom.js | 9 +++++++-- manage.js | 4 ++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/backup/fileSaveLoad.js b/backup/fileSaveLoad.js index d44e978f..4ac993ec 100644 --- a/backup/fileSaveLoad.js +++ b/backup/fileSaveLoad.js @@ -246,7 +246,7 @@ function importFromString(jsonString) { const styleElement = $('#style-' + event.target.dataset.id); if (styleElement) { scrollElementIntoView(styleElement); - animateElement(styleElement, {className: 'highlight'}); + animateElement(styleElement); } }; for (const block of $$('details')) { diff --git a/dom.js b/dom.js index b1443562..139619cc 100644 --- a/dom.js +++ b/dom.js @@ -46,8 +46,13 @@ function scrollElementIntoView(element) { } -function animateElement(element, {className, removeExtraClasses = [], remove = false}) { - return new Promise(resolve => { +function animateElement( + element, { + className = 'highlight', + removeExtraClasses = [], + remove = false, + } = {}) { + return element && new Promise(resolve => { element.addEventListener('animationend', function _() { element.removeEventListener('animationend', _); element.classList.remove( diff --git a/manage.js b/manage.js index 7589e8ff..09a4063e 100644 --- a/manage.js +++ b/manage.js @@ -342,7 +342,7 @@ Object.assign(handleEvent, { delete(event, entry) { const id = entry.styleId; const {name} = BG.cachedStyles.byId.get(id) || {}; - animateElement(entry, {className: 'highlight'}); + animateElement(entry); messageBox({ title: t('deleteStyleConfirm'), contents: name, @@ -420,7 +420,7 @@ function handleUpdate(style, {reason, method} = {}) { } filterAndAppend({entry}); if (!entry.matches('.hidden') && reason != 'import') { - animateElement(entry, {className: 'highlight'}); + animateElement(entry); scrollElementIntoView(entry); }