From 0dba0d8fde3d48da0633c656378902b7f68bb818 Mon Sep 17 00:00:00 2001 From: Filipa Lacerda Date: Wed, 5 Jul 2017 09:29:59 +0100 Subject: Changes after review: Use variables where code is repeated --- app/assets/javascripts/build.js | 9 +++++---- 1 file 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); -- cgit v1.2.1