From 6b675d8db69fb2d8c804ffc6c4c185fbe965921c Mon Sep 17 00:00:00 2001 From: Rob Sayre Date: Sat, 25 Jun 2011 09:42:59 -0700 Subject: [PATCH 1/3] Make the log auto-scroll if the scrollbar is near the bottom, but maintain position if it isn't. --- test/test_slave.html | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/test/test_slave.html b/test/test_slave.html index d685eeaf2..5652a5860 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(); } From cfcac65de4598f4a643e47656cc4ccc98f334adc Mon Sep 17 00:00:00 2001 From: Rob Sayre Date: Sat, 25 Jun 2011 09:51:27 -0700 Subject: [PATCH 2/3] Fix whitespace. --- test/test_slave.html | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/test_slave.html b/test/test_slave.html index 71ec7cacc..303a58c9b 100644 --- a/test/test_slave.html +++ b/test/test_slave.html @@ -200,8 +200,7 @@ function clear(ctx) { ctx.restore(); } -/* Auto-scroll if the scrollbar is near the bottom, otherwise do -nothing. */ +/* 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; From fc65ddb7dfff4971e8157fb58b31676bec398bd4 Mon Sep 17 00:00:00 2001 From: Rob Sayre Date: Sat, 25 Jun 2011 11:02:35 -0700 Subject: [PATCH 3/3] Still more whitespace fixing. --- test/test_slave.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_slave.html b/test/test_slave.html index 303a58c9b..07ac87388 100644 --- a/test/test_slave.html +++ b/test/test_slave.html @@ -203,7 +203,7 @@ function clear(ctx) { /* 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; + stdout.scrollTop = stdout.scrollHeight; } }