diff --git a/src/octoprint/static/js/app/viewmodels/terminal.js b/src/octoprint/static/js/app/viewmodels/terminal.js index 09a9188ca..6ee6586ce 100644 --- a/src/octoprint/static/js/app/viewmodels/terminal.js +++ b/src/octoprint/static/js/app/viewmodels/terminal.js @@ -277,6 +277,17 @@ $(function() { } }; + self.terminalScrollEvent = _.throttle(function () { + if (self.autoscrollEnabled()) { + var container = self.fancyFunctionality() ? $("#terminal-output") : $("#terminal-output-lowfi"); + var maxScroll = container[0].scrollHeight - container[0].offsetHeight; + + if (container.scrollTop() <= maxScroll ) { + self.autoscrollEnabled(false); + } + } + }, 250); + self.gotoTerminalCommand = function() { // skip if user highlights text. var sel = getSelection().toString(); @@ -289,6 +300,10 @@ $(function() { self.toggleAutoscroll = function() { self.autoscrollEnabled(!self.autoscrollEnabled()); + + if (self.autoscrollEnabled()) { + self.updateOutput(); + } }; self.selectAll = function() { diff --git a/src/octoprint/templates/tabs/terminal.jinja2 b/src/octoprint/templates/tabs/terminal.jinja2 index df5762601..ba6c20482 100644 --- a/src/octoprint/templates/tabs/terminal.jinja2 +++ b/src/octoprint/templates/tabs/terminal.jinja2 @@ -1,5 +1,5 @@
-
+