Make the log auto-scroll if the scrollbar is near the bottom, but maintain position if it isn't.
This commit is contained in:
		
							parent
							
								
									636a548b5d
								
							
						
					
					
						commit
						6b675d8db6
					
				@ -194,9 +194,17 @@ function clear(ctx) {
 | 
				
			|||||||
  ctx.restore();
 | 
					  ctx.restore();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Auto-scroll if the scrollbar is near the bottom, otherwise do
 | 
				
			||||||
 | 
					nothing. */
 | 
				
			||||||
 | 
					function checkScrolling() {
 | 
				
			||||||
 | 
					  if ((stdout.scrollHeight - stdout.scrollTop) <= stdout.offsetHeight) {
 | 
				
			||||||
 | 
					     stdout.scrollTop = stdout.scrollHeight;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function log(str) {
 | 
					function log(str) {
 | 
				
			||||||
  stdout.innerHTML += str;
 | 
					  stdout.innerHTML += str;
 | 
				
			||||||
  window.scrollTo(0, stdout.getBoundingClientRect().bottom);
 | 
					  checkScrolling();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
  </script>
 | 
					  </script>
 | 
				
			||||||
</head>
 | 
					</head>
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user