code cosmetics: animateElement() 'highlight' by default

This commit is contained in:
tophf 2017-06-27 23:00:24 +03:00
parent 1aa5c11b10
commit dc846aa7dd
3 changed files with 10 additions and 5 deletions

View File

@ -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')) {

9
dom.js
View File

@ -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(

View File

@ -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);
}