Skip to content

Commit 17f351b

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

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

web_src/js/components/RepoActionView.vue

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,22 @@ 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 && clientHeight >= logsContainerHeight) {
204+
const newLogsContainerHeight = this.$refs.stepsContainer.getBoundingClientRect().bottom + window.scrollY;
205+
window.scrollTo({top: clientHeight + (newLogsContainerHeight - logsContainerHeight), behavior: 'smooth'});
206+
}
196207
},
197208
198209
async fetchArtifacts() {
@@ -424,7 +435,7 @@ export function initRepositoryActionView() {
424435
</div>
425436
</div>
426437
427-
<div class="action-view-right">
438+
<div class="action-view-right" ref="stepsContainer">
428439
<div class="job-info-header">
429440
<div class="job-info-header-left">
430441
<h3 class="job-info-header-title">

0 commit comments

Comments
 (0)