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) {
|
2019-10-24 19:03:10 -07:00
|
|
|
smoothScroll(scroller, 0, /* horizontal */ false, /* preferFast */ true)
|
2019-03-18 09:09:24 -07:00
|
|
|
} else {
|
|
|
|
scroller.scrollTop = 0
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|