
* fix: use smooth scroll polyfill in Chrome for scroll-to-top * rename thunk to __thunk__ for safety
16 lines
411 B
JavaScript
16 lines
411 B
JavaScript
import { getScrollContainer } from './scrollContainer'
|
|
import { smoothScroll } from './smoothScroll'
|
|
|
|
export function scrollToTop (smooth) {
|
|
const scroller = getScrollContainer()
|
|
const { scrollTop } = scroller
|
|
if (scrollTop === 0) {
|
|
return false
|
|
}
|
|
if (smooth) {
|
|
smoothScroll(scroller, 0, /* horizontal */ false, /* preferFast */ true)
|
|
} else {
|
|
scroller.scrollTop = 0
|
|
}
|
|
return true
|
|
}
|