Skip to content

Commit

Permalink
Fix app/console: log auto scrolling when user isn't at the bottom
Browse files Browse the repository at this point in the history
  • Loading branch information
skybird23333 committed Dec 1, 2022
1 parent c81dd8b commit cccc6bb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
18 changes: 7 additions & 11 deletions app/components/Console/ConsoleComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,23 @@ export default {
},
methods: {
append(line, type) {
console.log(this.$refs.logview.scrollTop + 200, 'scrolltop')
console.log(this.$refs.logview.scrollHeight, 'scrollheight')
const isUserScrolledUp = !(this.$refs.logview.scrollTop + 200 == this.$refs.logview.scrollHeight)
this.lines.push({ text: line, type: type });
this.$nextTick(() => {
this.$refs.logview.scrollTop = this.$refs.logview.scrollHeight;
if (!isUserScrolledUp) {
this.$refs.logview.scrollTop = this.$refs.logview.scrollHeight;
}
});
},
async handleSend(evt) {
if (evt.keyCode !== 13) return
if (this.input === "") return;
this.$client.sendToProcessStdin(this.name, this.input);
this.pushLog({
type: "stdin",
text: this.input,
});
this.append(this.input, "stdin");
this.input = "";
},
pushLog(log) {
this.lines.push(log);
this.$nextTick(() => {
this.$refs.logview.scrollTop = this.$refs.logview.scrollHeight;
});
}
}
}
</script>
Expand Down
1 change: 0 additions & 1 deletion app/views/ProcessView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ export default {
this.$refs.console.append(`<div><span class="material-icons">event</span>${data.type}</div>`, data.type)
break;
}
console.log(data.type)
} catch (e) {
console.log(e)
}
Expand Down

0 comments on commit cccc6bb

Please sign in to comment.