export const DIRECTION_TOP = 'top';
export const DIRECTION_BOTTOM = 'bottom';

export const getPageCoordinates = direction => ({
    top: direction === DIRECTION_BOTTOM ? document.body.scrollHeight : 0,
    left: 0
});

export const getScrollOptions = (top = 0, left = 0, animate = true) => ({
    top,
    left,
    behavior: animate ? 'smooth' : 'auto'
});

function scrollTo({ top = 0, left = 0 }, animate = true) {
    window.scroll(getScrollOptions(top, left, animate));
}

export function scrollToTop(animate = true) {
    scrollTo(getPageCoordinates(DIRECTION_TOP), animate);
}

export function scrollToBottom(animate = true) {
    scrollTo(getPageCoordinates(DIRECTION_BOTTOM), animate);
}
