summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilipa Lacerda <filipa@gitlab.com>2017-07-05 09:29:59 +0100
committerFilipa Lacerda <filipa@gitlab.com>2017-07-05 09:29:59 +0100
commit0dba0d8fde3d48da0633c656378902b7f68bb818 (patch)
tree4c020451a679a88ae4cef2f89c3a9b2520baca09
parent9082fe07961ea6c274baa69f23a70fd8ed91401c (diff)
downloadgitlab-ce-34531-remove-scroll.tar.gz
Changes after review: Use variables where code is repeated34531-remove-scroll
-rw-r--r--app/assets/javascripts/build.js9
1 files changed, 5 insertions, 4 deletions
diff --git a/app/assets/javascripts/build.js b/app/assets/javascripts/build.js
index 74babedae89..1dfa064acfd 100644
--- a/app/assets/javascripts/build.js
+++ b/app/assets/javascripts/build.js
@@ -64,9 +64,10 @@ window.Build = (function () {
$(window)
.off('scroll')
.on('scroll', () => {
- if (this.$buildTraceOutput.prop('scrollHeight') > this.windowSize) {
+ const contentHeight = this.$buildTraceOutput.prop('scrollHeight');
+ if (contentHeight > this.windowSize) {
// means the user did not scroll, the content was updated.
- this.windowSize = this.$buildTraceOutput.prop('scrollHeight');
+ this.windowSize = contentHeight;
} else {
// User scrolled
this.hasBeenScrolled = true;
@@ -113,7 +114,7 @@ window.Build = (function () {
if (this.canScroll()) {
if (currentPosition > 0 &&
- (document.body.scrollHeight - document.body.scrollTop !== windowHeight)) {
+ (document.body.scrollHeight - currentPosition !== windowHeight)) {
// User is in the middle of the log
this.toggleDisableButton(this.$scrollTopBtn, false);
@@ -123,7 +124,7 @@ window.Build = (function () {
this.toggleDisableButton(this.$scrollTopBtn, true);
this.toggleDisableButton(this.$scrollBottomBtn, false);
- } else if (document.body.scrollHeight - document.body.scrollTop === windowHeight) {
+ } else if (document.body.scrollHeight - currentPosition === windowHeight) {
// User is at the bottom of the build log.
this.toggleDisableButton(this.$scrollTopBtn, false);