]> git.parisson.com Git - pdf.js.git/commitdiff
Make the log auto-scroll if the scrollbar is near the bottom, but maintain position...
authorRob Sayre <sayrer@gmail.com>
Sat, 25 Jun 2011 16:42:59 +0000 (09:42 -0700)
committerRob Sayre <sayrer@gmail.com>
Sat, 25 Jun 2011 16:42:59 +0000 (09:42 -0700)
test/test_slave.html

index d685eeaf233f952913e5651419401f024c68f6af..5652a5860b773f7d92f504edb911c75dc023f54d 100644 (file)
@@ -194,9 +194,17 @@ function clear(ctx) {
   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) {
   stdout.innerHTML += str;
-  window.scrollTo(0, stdout.getBoundingClientRect().bottom);
+  checkScrolling();
 }
   </script>
 </head>