code cosmetics: animateElement() 'highlight' by default
This commit is contained in:
		
							parent
							
								
									1aa5c11b10
								
							
						
					
					
						commit
						dc846aa7dd
					
				| 
						 | 
					@ -246,7 +246,7 @@ function importFromString(jsonString) {
 | 
				
			||||||
      const styleElement = $('#style-' + event.target.dataset.id);
 | 
					      const styleElement = $('#style-' + event.target.dataset.id);
 | 
				
			||||||
      if (styleElement) {
 | 
					      if (styleElement) {
 | 
				
			||||||
        scrollElementIntoView(styleElement);
 | 
					        scrollElementIntoView(styleElement);
 | 
				
			||||||
        animateElement(styleElement, {className: 'highlight'});
 | 
					        animateElement(styleElement);
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
    for (const block of $$('details')) {
 | 
					    for (const block of $$('details')) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										9
									
								
								dom.js
									
									
									
									
									
								
							
							
						
						
									
										9
									
								
								dom.js
									
									
									
									
									
								
							| 
						 | 
					@ -46,8 +46,13 @@ function scrollElementIntoView(element) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function animateElement(element, {className, removeExtraClasses = [], remove = false}) {
 | 
					function animateElement(
 | 
				
			||||||
  return new Promise(resolve => {
 | 
					  element, {
 | 
				
			||||||
 | 
					    className = 'highlight',
 | 
				
			||||||
 | 
					    removeExtraClasses = [],
 | 
				
			||||||
 | 
					    remove = false,
 | 
				
			||||||
 | 
					  } = {}) {
 | 
				
			||||||
 | 
					  return element && new Promise(resolve => {
 | 
				
			||||||
    element.addEventListener('animationend', function _() {
 | 
					    element.addEventListener('animationend', function _() {
 | 
				
			||||||
      element.removeEventListener('animationend', _);
 | 
					      element.removeEventListener('animationend', _);
 | 
				
			||||||
      element.classList.remove(
 | 
					      element.classList.remove(
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -342,7 +342,7 @@ Object.assign(handleEvent, {
 | 
				
			||||||
  delete(event, entry) {
 | 
					  delete(event, entry) {
 | 
				
			||||||
    const id = entry.styleId;
 | 
					    const id = entry.styleId;
 | 
				
			||||||
    const {name} = BG.cachedStyles.byId.get(id) || {};
 | 
					    const {name} = BG.cachedStyles.byId.get(id) || {};
 | 
				
			||||||
    animateElement(entry, {className: 'highlight'});
 | 
					    animateElement(entry);
 | 
				
			||||||
    messageBox({
 | 
					    messageBox({
 | 
				
			||||||
      title: t('deleteStyleConfirm'),
 | 
					      title: t('deleteStyleConfirm'),
 | 
				
			||||||
      contents: name,
 | 
					      contents: name,
 | 
				
			||||||
| 
						 | 
					@ -420,7 +420,7 @@ function handleUpdate(style, {reason, method} = {}) {
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  filterAndAppend({entry});
 | 
					  filterAndAppend({entry});
 | 
				
			||||||
  if (!entry.matches('.hidden') && reason != 'import') {
 | 
					  if (!entry.matches('.hidden') && reason != 'import') {
 | 
				
			||||||
    animateElement(entry, {className: 'highlight'});
 | 
					    animateElement(entry);
 | 
				
			||||||
    scrollElementIntoView(entry);
 | 
					    scrollElementIntoView(entry);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user