fixup 362d9444: never scroll manage page on toggling a visible entry
This commit is contained in:
		
							parent
							
								
									e6109d509b
								
							
						
					
					
						commit
						6f0dd5e9b6
					
				
							
								
								
									
										12
									
								
								js/dom.js
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								js/dom.js
									
									
									
									
									
								
							| 
						 | 
				
			
			@ -89,14 +89,14 @@ function onDOMready() {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
function scrollElementIntoView(element) {
 | 
			
		||||
function scrollElementIntoView(element, {invalidMarginRatio = .25} = {}) {
 | 
			
		||||
  // align to the top/bottom of the visible area if wasn't visible
 | 
			
		||||
  const bounds = element.getBoundingClientRect();
 | 
			
		||||
  const boundsContainer = element.parentNode.getBoundingClientRect();
 | 
			
		||||
  const {top, height} = element.getBoundingClientRect();
 | 
			
		||||
  const {top: parentTop, bottom: parentBottom} = element.parentNode.getBoundingClientRect();
 | 
			
		||||
  const windowHeight = window.innerHeight;
 | 
			
		||||
  if (bounds.top < Math.max(boundsContainer.top, windowHeight / 4) ||
 | 
			
		||||
      bounds.top > Math.min(boundsContainer.bottom, windowHeight) - bounds.height - windowHeight / 4) {
 | 
			
		||||
    window.scrollBy(0, bounds.top - windowHeight / 2 + bounds.height);
 | 
			
		||||
  if (top < Math.max(parentTop, windowHeight * invalidMarginRatio) ||
 | 
			
		||||
      top > Math.min(parentBottom, windowHeight) - height - windowHeight * invalidMarginRatio) {
 | 
			
		||||
    window.scrollBy(0, top - windowHeight / 2 + height);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -406,7 +406,7 @@ function handleUpdate(style, {reason, method} = {}) {
 | 
			
		|||
  filterAndAppend({entry});
 | 
			
		||||
  if (!entry.matches('.hidden') && reason !== 'import') {
 | 
			
		||||
    animateElement(entry);
 | 
			
		||||
    scrollElementIntoView(entry);
 | 
			
		||||
    scrollElementIntoView(entry, {invalidMarginRatio: 0});
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  function handleToggledOrCodeOnly() {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user