pinafore/src/routes/_utils/scrollToTop.js

17 lines
360 B
JavaScript
Raw Normal View History

import { getScrollContainer } from './scrollContainer'
import { smoothScroll } from './smoothScroll'
export function scrollToTop (smooth) {
let scroller = getScrollContainer()
let { scrollTop } = scroller
if (scrollTop === 0) {
return false
}
if (smooth) {
smoothScroll(scroller, 0)
} else {
scroller.scrollTop = 0
}
return true
}