From 66c323a7a0e13e3d2f25708185e7e8a8f02c4145 Mon Sep 17 00:00:00 2001 From: rsiddharth Date: Sat, 12 Oct 2019 20:07:13 -0400 Subject: nfsw/static/io.js: Update auto scrolling. Don't auto scroll if user initiates an up scroll. --- nfsw/static/io.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/nfsw/static/io.js b/nfsw/static/io.js index af11675..36965c5 100644 --- a/nfsw/static/io.js +++ b/nfsw/static/io.js @@ -11,6 +11,7 @@ document.addEventListener('DOMContentLoaded', function() { var qipoff = function() { window.qip = false; + ioconsole.autoScroll = true; }; var spit = function(response) { var gdg = 'Oops! getting gobbledygook from server'; @@ -65,6 +66,7 @@ document.addEventListener('DOMContentLoaded', function() { var iipoff = function() { window.iip = false; + ioconsole.autoScroll = true; }; var spit = function(response, status) { var r; @@ -157,7 +159,11 @@ document.addEventListener('DOMContentLoaded', function() { ioconsole.appendChild(p); } p.append(txt.substring(0, 1)); - p.scrollIntoView(); + + if (ioconsole.autoScroll) { + p.scrollIntoView(false); + } + window.setTimeout( barfslow, 25, @@ -170,6 +176,19 @@ document.addEventListener('DOMContentLoaded', function() { return ''; } var ioconsole = document.getElementsByClassName('console')[0]; + ioconsole.onscroll = function(e) { + if (!window.qip && !window.iip) { + return; + } + + if (e.target.scrollTop < e.target.lastScrollTop) { + e.target.autoScroll = false; + } + + e.target.lastScrollTop = e.target.scrollTop; + }; + ioconsole.lastScrollTop = ioconsole.scrollTop; + ioconsole.autoScroll = true; /** -- cgit v1.2.3