Fix auto2top in mobile

This commit is contained in:
qingwei.li 2016-12-17 15:08:44 +08:00
commit 299c31dff9
4 changed files with 21 additions and 6 deletions

View file

@ -1,10 +1,11 @@
import { isMobile } from './util'
/**
* Active sidebar when scroll
* @link https://buble.surge.sh/
*/
export function scrollActiveSidebar () {
if (/mobile/i.test(navigator.userAgent)) return
if (isMobile()) return
const anchors = document.querySelectorAll('.anchor')
const nav = {}
@ -92,7 +93,10 @@ export function bindToggle (dom) {
}
let cacheContentDOM
export function scroll2Top (dom) {
cacheContentDOM = cacheContentDOM || document.querySelector(dom)
export function scroll2Top () {
if (!cacheContentDOM) {
const dom = isMobile() ? 'body' : 'section.content'
cacheContentDOM = document.querySelector(dom)
}
cacheContentDOM.scrollTop = 0
}