This commit is contained in:
tamaina 2022-02-03 04:55:15 +09:00
parent a2f16c1364
commit a7dd3e9324

View File

@ -90,17 +90,26 @@ export function scrollToTop(el: HTMLElement, options: { behavior?: ScrollBehavio
/** /**
* Scroll to Bottom * Scroll to Bottom
* >
*
* @param el Content element * @param el Content element
* @param options Scroll options * @param options Scroll options
* @param container Scroll container element * @param container Scroll container element
* @param addSticky To add sticky-top or not * @param sticky To add sticky-top
* @param mobileButtons To add mobile buttons
*/ */
export function scrollToBottom(el: HTMLElement, options: ScrollToOptions = {}, container = getScrollContainer(el), addSticky: boolean = true) { export function scrollToBottom(
const addStickyTop = addSticky ? getStickyTop(el, container) : 0; el: HTMLElement,
options: ScrollToOptions = {},
container = getScrollContainer(el),
) {
if (container) { if (container) {
container.scroll({ top: el.scrollHeight - container.clientHeight + addStickyTop || 0, ...options }); container.scroll({ top: el.scrollHeight - container.clientHeight + getStickyTop(el, container) || 0, ...options });
} else { } else {
window.scroll({ top: el.scrollHeight - window.innerHeight + addStickyTop || 0, ...options }); window.scroll({
top: (el.scrollHeight - window.innerHeight + getStickyTop(el, container) + (window.innerWidth <= 500 ? 96 : 0)) || 0,
...options
});
} }
} }