mirror of
https://gitee.com/docsifyjs/docsify.git
synced 2024-12-02 20:20:30 +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
|
## 1.1.1
|
||||||
### Bug fixes
|
### Bug fixes
|
||||||
- Optimize progress bar
|
- Optimize progress bar
|
||||||
|
10
src/event.js
10
src/event.js
@ -1,10 +1,11 @@
|
|||||||
|
import { isMobile } from './util'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Active sidebar when scroll
|
* Active sidebar when scroll
|
||||||
* @link https://buble.surge.sh/
|
* @link https://buble.surge.sh/
|
||||||
*/
|
*/
|
||||||
export function scrollActiveSidebar () {
|
export function scrollActiveSidebar () {
|
||||||
if (/mobile/i.test(navigator.userAgent)) return
|
if (isMobile()) return
|
||||||
|
|
||||||
const anchors = document.querySelectorAll('.anchor')
|
const anchors = document.querySelectorAll('.anchor')
|
||||||
const nav = {}
|
const nav = {}
|
||||||
@ -92,7 +93,10 @@ export function bindToggle (dom) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let cacheContentDOM
|
let cacheContentDOM
|
||||||
export function scroll2Top (dom) {
|
export function scroll2Top () {
|
||||||
cacheContentDOM = cacheContentDOM || document.querySelector(dom)
|
if (!cacheContentDOM) {
|
||||||
|
const dom = isMobile() ? 'body' : 'section.content'
|
||||||
|
cacheContentDOM = document.querySelector(dom)
|
||||||
|
}
|
||||||
cacheContentDOM.scrollTop = 0
|
cacheContentDOM.scrollTop = 0
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ export function renderArticle (content) {
|
|||||||
renderSidebar.rendered = false
|
renderSidebar.rendered = false
|
||||||
renderNavbar.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'] = div
|
||||||
}
|
}
|
||||||
|
|
||||||
CACHE['loading'].style.opacity = 1
|
|
||||||
CACHE['loading'].style.width = num + '%'
|
|
||||||
if (num >= 95) {
|
if (num >= 95) {
|
||||||
clearTimeout(renderLoading.cacheTImeout)
|
clearTimeout(renderLoading.cacheTImeout)
|
||||||
renderLoading.cacheTImeout = setTimeout(_ => {
|
renderLoading.cacheTImeout = setTimeout(_ => {
|
||||||
CACHE['loading'].style.opacity = 0
|
CACHE['loading'].style.opacity = 0
|
||||||
CACHE['loading'].style.width = '0%'
|
CACHE['loading'].style.width = '0%'
|
||||||
}, 200)
|
}, 200)
|
||||||
|
} else {
|
||||||
|
CACHE['loading'].style.opacity = 1
|
||||||
|
CACHE['loading'].style.width = num + '%'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,3 +95,8 @@ export function getRoute () {
|
|||||||
|
|
||||||
return route
|
return route
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isMobile () {
|
||||||
|
return /mobile/i.test(navigator.userAgent)
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user