I have code like this using jQuery Terminal:
function show() {
for (var i = 0; i < 100; ++i) {
this.echo('line ' + i, {
flush: false
});
}
this.flush();
setTimeout(function() {
//this.flush();
}, 0);
}
var term = $('body').terminal({
show: show
}, {
onBlur: function() {
return false;
},
onInit: function(term) {
show.apply(term);
}
});
and inside this codepen the the lines are not show up until I resize horizontally the browser window. It work when I put flush in setTimeout 0:
setTimeout(function() {
term.flush();
}, 0);
It work normally when I run the same code (without setTimeout) in local server. I've also tried to embed the code in iframe and It also run as expected. And other thing when I execute command show (type show and press enter) the executed command and prompt is add at the end (after the lines added by echo) but when I resize the window they are in placed before the lines as they should.
Anybody have a clue why this is happening? Why is the code executed differently locally and in codepen?
I've trid to setup breakpoints in jquery.terminal-src.js file but didn't figure out why flush don't make lines show up. When I step throught the code it seems that output_buffer array is empty when flush is called but somehow the lines show up when I resize the window and resize method is executed.