mirror of
https://gitee.com/docsifyjs/docsify.git
synced 2024-11-30 11:08:58 +08:00
Fix auto2top in mobile
This commit is contained in:
parent
aa1d84b513
commit
299c31dff9
@ -1,3 +1,8 @@
|
||||
## 1.1.2
|
||||
### Bug fixes
|
||||
- fix failed `auto2top` in mobile
|
||||
|
||||
|
||||
## 1.1.1
|
||||
### Bug fixes
|
||||
- Optimize progress bar
|
||||
|
10
src/event.js
10
src/event.js
@ -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
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ export function renderArticle (content) {
|
||||
renderSidebar.rendered = false
|
||||
renderNavbar.rendered = false
|
||||
|
||||
if (OPTIONS.auto2top) scroll2Top('section.content')
|
||||
if (OPTIONS.auto2top) scroll2Top()
|
||||
}
|
||||
|
||||
/**
|
||||
@ -123,14 +123,15 @@ export function renderLoading ({ loaded, total }) {
|
||||
CACHE['loading'] = div
|
||||
}
|
||||
|
||||
CACHE['loading'].style.opacity = 1
|
||||
CACHE['loading'].style.width = num + '%'
|
||||
if (num >= 95) {
|
||||
clearTimeout(renderLoading.cacheTImeout)
|
||||
renderLoading.cacheTImeout = setTimeout(_ => {
|
||||
CACHE['loading'].style.opacity = 0
|
||||
CACHE['loading'].style.width = '0%'
|
||||
}, 200)
|
||||
} else {
|
||||
CACHE['loading'].style.opacity = 1
|
||||
CACHE['loading'].style.width = num + '%'
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -95,3 +95,8 @@ export function getRoute () {
|
||||
|
||||
return route
|
||||
}
|
||||
|
||||
export function isMobile () {
|
||||
return /mobile/i.test(navigator.userAgent)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user