Skip to content

Commit 1bf3cd3

Browse files
committed
Add action auto-scrolling
1 parent 3f26fe2 commit 1bf3cd3

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

web_src/js/components/RepoActionView.vue

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,24 @@ const sfc = {
188188
},
189189
190190
appendLogs(stepIndex, logLines, startTime) {
191+
// position of the client view relative to the website top
192+
const clientHeight = document.documentElement.clientHeight + window.scrollY;
193+
// height of the logs container relative to the website top
194+
const logsContainerHeight = this.$refs.stepsContainer.getBoundingClientRect().bottom + window.scrollY;
195+
191196
for (const line of logLines) {
192197
// TODO: group support: ##[group]GroupTitle , ##[endgroup]
193198
const el = this.getLogsContainer(stepIndex);
194199
el.append(this.createLogLine(line, startTime, stepIndex));
195200
}
201+
202+
// scrolls to the bottom if job is running and the bottom of the logs container is visible
203+
if (!this.run.done && logLines.length > 0) {
204+
if (clientHeight >= logsContainerHeight) {
205+
const newLogsContainerHeight = this.$refs.stepsContainer.getBoundingClientRect().bottom + window.scrollY;
206+
window.scrollTo({top: clientHeight + (newLogsContainerHeight - logsContainerHeight), behavior: 'smooth'});
207+
}
208+
}
196209
},
197210
198211
async fetchArtifacts() {
@@ -424,7 +437,7 @@ export function initRepositoryActionView() {
424437
</div>
425438
</div>
426439
427-
<div class="action-view-right">
440+
<div class="action-view-right" ref="stepsContainer">
428441
<div class="job-info-header">
429442
<div class="job-info-header-left">
430443
<h3 class="job-info-header-title">

0 commit comments

Comments
 (0)