Commit dacef283 authored by Tim Zallmann's avatar Tim Zallmann

Merge branch '41120-performance-bar-auto-scroll' into 'master'

Resolve "Performance bar prevent the auto-scroll-to-bottom when visiting a job's page"

Closes #41120

See merge request gitlab-org/gitlab-ce!16084
parents fced41b1 a276391b
...@@ -96,14 +96,15 @@ export default class Job { ...@@ -96,14 +96,15 @@ export default class Job {
// eslint-disable-next-line class-methods-use-this // eslint-disable-next-line class-methods-use-this
canScroll() { canScroll() {
return this.$document.height() > this.$window.height(); return $(document).height() > $(window).height();
} }
toggleScroll() { toggleScroll() {
const currentPosition = this.$document.scrollTop(); const $document = $(document);
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 (this.canScroll()) {
if (currentPosition > 0 && if (currentPosition > 0 &&
(scrollHeight - currentPosition !== windowHeight)) { (scrollHeight - currentPosition !== windowHeight)) {
...@@ -127,18 +128,22 @@ export default class Job { ...@@ -127,18 +128,22 @@ export default class Job {
this.toggleDisableButton(this.$scrollBottomBtn, true); this.toggleDisableButton(this.$scrollBottomBtn, true);
} }
} }
// eslint-disable-next-line class-methods-use-this
isScrolledToBottom() { isScrolledToBottom() {
const currentPosition = this.$document.scrollTop(); const $document = $(document);
const scrollHeight = this.$document.height();
const currentPosition = $document.scrollTop();
const scrollHeight = $document.height();
const windowHeight = $(window).height();
const windowHeight = this.$window.height();
return scrollHeight - currentPosition === windowHeight; return scrollHeight - currentPosition === windowHeight;
} }
// eslint-disable-next-line class-methods-use-this // eslint-disable-next-line class-methods-use-this
scrollDown() { scrollDown() {
this.$document.scrollTop(this.$document.height()); const $document = $(document);
$document.scrollTop($document.height());
} }
scrollToBottom() { scrollToBottom() {
...@@ -148,7 +153,7 @@ export default class Job { ...@@ -148,7 +153,7 @@ export default class Job {
} }
scrollToTop() { scrollToTop() {
this.$document.scrollTop(0); $(document).scrollTop(0);
this.hasBeenScrolled = true; this.hasBeenScrolled = true;
this.toggleScroll(); this.toggleScroll();
} }
......
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