From: Rob Sayre Date: Sat, 25 Jun 2011 16:42:59 +0000 (-0700) Subject: Make the log auto-scroll if the scrollbar is near the bottom, but maintain position... X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=22538d6697e448b20d2ae0f0c66161f85e540c00;p=pdf.js.git Make the log auto-scroll if the scrollbar is near the bottom, but maintain position if it isn't. --- diff --git a/test/test_slave.html b/test/test_slave.html index d685eea..5652a58 100644 --- a/test/test_slave.html +++ b/test/test_slave.html @@ -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(); }