summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/lib/utils/scroll_utils.js
blob: 9313b570863ee173cd118b8410e84d793f92e7c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import $ from 'jquery';

export const canScroll = () => $(document).height() > $(window).height();

/**
 * Checks if the entire page is scrolled down all the way to the bottom
 */
export const isScrolledToBottom = () => {
  const $document = $(document);

  const currentPosition = $document.scrollTop();
  const scrollHeight = $document.height();

  const windowHeight = $(window).height();

  return scrollHeight - currentPosition === windowHeight;
};

export const scrollDown = () => {
  const $document = $(document);
  $document.scrollTop($document.height());
};

export const toggleDisableButton = ($button, disable) => {
  if (disable && $button.prop('disabled')) return;
  $button.prop('disabled', disable);
};

export default {};