diff options
-rw-r--r-- | js/terminal-animation.js | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/js/terminal-animation.js b/js/terminal-animation.js index f43fce1..28f1833 100644 --- a/js/terminal-animation.js +++ b/js/terminal-animation.js @@ -69,18 +69,15 @@ $this.content.append(list); } - $this.flush(); + $this.flush(function() { + $this.console.scrollTop(0); + }); }; - $this.flush = function() { - var done = function() { - var height = $this.console.height(); - $this.console.scrollTop(height); - }; - + $this.flush = function(done) { var run = function() { if ($this.elements.contents().length == 0) { - done.call(); + if (done) done.call(); return; } @@ -125,7 +122,11 @@ $this.elements.prepend(element); } - $this.flush(); + $this.flush(function() { + var height = $this.content.height(); + $this.console.scrollTop(height); + }); + }; $this.next = function(callback) { @@ -160,14 +161,20 @@ } else { $this.content.append(element); - $this.flush(); + $this.flush(function() { + var height = $this.content.height(); + $this.console.scrollTop(height); + }); if (callback) callback.call(); } }; $this.reset = function() { $this.elements.append($this.content.contents().detach()); - $this.flush(); + $this.flush(function() { + var height = $this.content.height(); + $this.console.scrollTop(height); + }); }; $this.init(); |