2019-03-18 09:09:24 -07:00
|
|
|
import { getScrollContainer } from './scrollContainer'
|
|
|
|
import { smoothScroll } from './smoothScroll'
|
|
|
|
|
|
|
|
export function scrollToTop (smooth) {
|
2019-08-03 13:49:37 -07:00
|
|
|
const scroller = getScrollContainer()
|
|
|
|
const { scrollTop } = scroller
|
2019-03-18 09:09:24 -07:00
|
|
|
if (scrollTop === 0) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
if (smooth) {
|
|
|
|
smoothScroll(scroller, 0)
|
|
|
|
} else {
|
|
|
|
scroller.scrollTop = 0
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|