2018-11-08 19:23:39 +05:30
|
|
|
import { isInIssuePage, isInMRPage, isInEpicPage } from './common_utils';
|
2017-09-10 17:25:29 +05:30
|
|
|
|
|
|
|
export const addClassIfElementExists = (element, className) => {
|
|
|
|
if (element) {
|
|
|
|
element.classList.add(className);
|
|
|
|
}
|
|
|
|
};
|
2018-05-09 12:01:36 +05:30
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
export const isInVueNoteablePage = () => isInIssuePage() || isInEpicPage() || isInMRPage();
|
2019-02-15 15:39:39 +05:30
|
|
|
|
|
|
|
export const canScrollUp = ({ scrollTop }, margin = 0) => scrollTop > margin;
|
|
|
|
|
|
|
|
export const canScrollDown = ({ scrollTop, offsetHeight, scrollHeight }, margin = 0) =>
|
|
|
|
scrollTop + offsetHeight < scrollHeight - margin;
|
2020-06-23 00:09:42 +05:30
|
|
|
|
|
|
|
export const toggleContainerClasses = (containerEl, classList) => {
|
|
|
|
if (containerEl) {
|
|
|
|
// eslint-disable-next-line array-callback-return
|
|
|
|
Object.entries(classList).map(([key, value]) => {
|
|
|
|
if (value) {
|
|
|
|
containerEl.classList.add(key);
|
|
|
|
} else {
|
|
|
|
containerEl.classList.remove(key);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|