Commit 82b5fe51 authored by Filipa Lacerda's avatar Filipa Lacerda

Uses jQuery to scroll since setting document.body.scrollTop does not work in firefox

parent 4c89929f
...@@ -64,7 +64,7 @@ window.Build = (function () { ...@@ -64,7 +64,7 @@ window.Build = (function () {
$(window) $(window)
.off('scroll') .off('scroll')
.on('scroll', () => { .on('scroll', () => {
const contentHeight = this.$buildTraceOutput.prop('scrollHeight'); const contentHeight = this.$buildTraceOutput.height();
if (contentHeight > this.windowSize) { if (contentHeight > this.windowSize) {
// means the user did not scroll, the content was updated. // means the user did not scroll, the content was updated.
this.windowSize = contentHeight; this.windowSize = contentHeight;
...@@ -105,16 +105,17 @@ window.Build = (function () { ...@@ -105,16 +105,17 @@ window.Build = (function () {
}; };
Build.prototype.canScroll = function () { Build.prototype.canScroll = function () {
return document.body.scrollHeight > window.innerHeight; return $(document).height() > $(window).height();
}; };
Build.prototype.toggleScroll = function () { Build.prototype.toggleScroll = function () {
const currentPosition = document.body.scrollTop; const currentPosition = $(document).scrollTop();
const windowHeight = window.innerHeight; const scrollHeight = $(document).height();
const windowHeight = $(window).height();
if (this.canScroll()) { if (this.canScroll()) {
if (currentPosition > 0 && if (currentPosition > 0 &&
(document.body.scrollHeight - currentPosition !== windowHeight)) { (scrollHeight - currentPosition !== windowHeight)) {
// User is in the middle of the log // User is in the middle of the log
this.toggleDisableButton(this.$scrollTopBtn, false); this.toggleDisableButton(this.$scrollTopBtn, false);
...@@ -124,7 +125,7 @@ window.Build = (function () { ...@@ -124,7 +125,7 @@ window.Build = (function () {
this.toggleDisableButton(this.$scrollTopBtn, true); this.toggleDisableButton(this.$scrollTopBtn, true);
this.toggleDisableButton(this.$scrollBottomBtn, false); this.toggleDisableButton(this.$scrollBottomBtn, false);
} else if (document.body.scrollHeight - currentPosition === windowHeight) { } else if (scrollHeight - currentPosition === windowHeight) {
// User is at the bottom of the build log. // User is at the bottom of the build log.
this.toggleDisableButton(this.$scrollTopBtn, false); this.toggleDisableButton(this.$scrollTopBtn, false);
...@@ -137,7 +138,7 @@ window.Build = (function () { ...@@ -137,7 +138,7 @@ window.Build = (function () {
}; };
Build.prototype.scrollDown = function () { Build.prototype.scrollDown = function () {
document.body.scrollTop = document.body.scrollHeight; $(document).scrollTop($(document).height());
}; };
Build.prototype.scrollToBottom = function () { Build.prototype.scrollToBottom = function () {
...@@ -147,7 +148,7 @@ window.Build = (function () { ...@@ -147,7 +148,7 @@ window.Build = (function () {
}; };
Build.prototype.scrollToTop = function () { Build.prototype.scrollToTop = function () {
document.body.scrollTop = 0; $(document).scrollTop(0);
this.hasBeenScrolled = true; this.hasBeenScrolled = true;
this.toggleScroll(); this.toggleScroll();
}; };
...@@ -178,7 +179,7 @@ window.Build = (function () { ...@@ -178,7 +179,7 @@ window.Build = (function () {
this.state = log.state; this.state = log.state;
} }
this.windowSize = this.$buildTraceOutput.prop('scrollHeight'); this.windowSize = this.$buildTraceOutput.height();
if (log.append) { if (log.append) {
this.$buildTraceOutput.append(log.html); this.$buildTraceOutput.append(log.html);
......
---
title: Use jQuery to control scroll behavior in job log for cross browser consistency
merge_request:
author:
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment