summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/lib/utils/scroll_utils.js
diff options
context:
space:
mode:
authorAndreas Kämmerle <andreas.kaemmerle@gmail.com>2018-07-03 15:30:36 +0200
committerAndreas Kämmerle <andreas.kaemmerle@gmail.com>2018-07-03 15:30:36 +0200
commite4a310113a3a5784be863151e5bcecacb23aa244 (patch)
tree79f9019b2e001a192eae3569b5746ba9c4ec9476 /app/assets/javascripts/lib/utils/scroll_utils.js
parentd505b48806c0880ac810374973c4b9ba802c26e8 (diff)
parentc489d53b2e2eecb22f8dc7034da142221220e89f (diff)
downloadgitlab-ce-e4a310113a3a5784be863151e5bcecacb23aa244.tar.gz
Merge branch 'master' of https://gitlab.com/gitlab-org/gitlab-ce into update-template-name-via-sentence-case
# Conflicts: # .gitlab/issue_templates/Feature proposal.md
Diffstat (limited to 'app/assets/javascripts/lib/utils/scroll_utils.js')
-rw-r--r--app/assets/javascripts/lib/utils/scroll_utils.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/app/assets/javascripts/lib/utils/scroll_utils.js b/app/assets/javascripts/lib/utils/scroll_utils.js
new file mode 100644
index 00000000000..9313b570863
--- /dev/null
+++ b/app/assets/javascripts/lib/utils/scroll_utils.js
@@ -0,0 +1,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 {};