From 7c636732fba98935922ffaadc49b328417e9036c Mon Sep 17 00:00:00 2001 From: Filipa Lacerda Date: Thu, 21 Dec 2017 15:48:24 +0000 Subject: Use non cached variables to get scroll position because of the performance bar --- app/assets/javascripts/job.js | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/app/assets/javascripts/job.js b/app/assets/javascripts/job.js index 198a7823381..e1b2506e437 100644 --- a/app/assets/javascripts/job.js +++ b/app/assets/javascripts/job.js @@ -96,14 +96,14 @@ export default class Job { // eslint-disable-next-line class-methods-use-this canScroll() { - return this.$document.height() > this.$window.height(); + return $(document).height() > $(window).height(); } toggleScroll() { - const currentPosition = this.$document.scrollTop(); - const scrollHeight = this.$document.height(); + const currentPosition = $(document).scrollTop(); + const scrollHeight = $(document).height(); - const windowHeight = this.$window.height(); + const windowHeight = $(window).height(); if (this.canScroll()) { if (currentPosition > 0 && (scrollHeight - currentPosition !== windowHeight)) { @@ -127,18 +127,22 @@ export default class Job { this.toggleDisableButton(this.$scrollBottomBtn, true); } } - + // eslint-disable-next-line class-methods-use-this isScrolledToBottom() { - const currentPosition = this.$document.scrollTop(); - const scrollHeight = this.$document.height(); + const $document = $(document); + + const currentPosition = $document.scrollTop(); + const scrollHeight = $document.height(); + + const windowHeight = $(window).height(); - const windowHeight = this.$window.height(); return scrollHeight - currentPosition === windowHeight; } // eslint-disable-next-line class-methods-use-this scrollDown() { - this.$document.scrollTop(this.$document.height()); + const $document = $(document); + $document.scrollTop($document.height()); } scrollToBottom() { @@ -148,7 +152,7 @@ export default class Job { } scrollToTop() { - this.$document.scrollTop(0); + $(document).scrollTop(0); this.hasBeenScrolled = true; this.toggleScroll(); } -- cgit v1.2.1 From a276391b18e113d443716bd719bb9f70e3fd3d99 Mon Sep 17 00:00:00 2001 From: Filipa Lacerda Date: Tue, 2 Jan 2018 21:06:56 +0000 Subject: Cache document query --- app/assets/javascripts/job.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/job.js b/app/assets/javascripts/job.js index f94b0fdbb5e..8f32dcc94e2 100644 --- a/app/assets/javascripts/job.js +++ b/app/assets/javascripts/job.js @@ -100,8 +100,9 @@ export default class Job { } toggleScroll() { - const currentPosition = $(document).scrollTop(); - const scrollHeight = $(document).height(); + const $document = $(document); + const currentPosition = $document.scrollTop(); + const scrollHeight = $document.height(); const windowHeight = $(window).height(); if (this.canScroll()) { -- cgit v1.2.1