2019-03-18 17:09:24 +01:00
|
|
|
import { getScrollContainer } from './scrollContainer'
|
|
|
|
import { smoothScroll } from './smoothScroll'
|
|
|
|
|
|
|
|
export function scrollToTop (smooth) {
|
2019-08-03 22:49:37 +02:00
|
|
|
const scroller = getScrollContainer()
|
|
|
|
const { scrollTop } = scroller
|
2019-03-18 17:09:24 +01:00
|
|
|
if (scrollTop === 0) {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
if (smooth) {
|
2019-10-25 04:03:10 +02:00
|
|
|
smoothScroll(scroller, 0, /* horizontal */ false, /* preferFast */ true)
|
2019-03-18 17:09:24 +01:00
|
|
|
} else {
|
|
|
|
scroller.scrollTop = 0
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
}
|