summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/lib/utils/dom_utils.js
blob: 7933c234384c7fee0ba48f27f0bce701f06475cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import { isInIssuePage, isInMRPage, isInEpicPage } from './common_utils';

export const addClassIfElementExists = (element, className) => {
  if (element) {
    element.classList.add(className);
  }
};

export const isInVueNoteablePage = () => isInIssuePage() || isInEpicPage() || isInMRPage();

export const canScrollUp = ({ scrollTop }, margin = 0) => scrollTop > margin;

export const canScrollDown = ({ scrollTop, offsetHeight, scrollHeight }, margin = 0) =>
  scrollTop + offsetHeight < scrollHeight - margin;