mirror of
https://gitee.com/docsifyjs/docsify.git
synced 2024-12-02 20:20:30 +08:00
bump 1.1.7
This commit is contained in:
parent
73a193d602
commit
48912a0b79
@ -21,8 +21,13 @@ function load (url, method, loading) {
|
|||||||
if ( error === void 0 ) error = function () {};
|
if ( error === void 0 ) error = function () {};
|
||||||
|
|
||||||
if (loading) {
|
if (loading) {
|
||||||
|
var id = setInterval(function (_) { return loading({ step: Math.floor(Math.random() * 5 + 1) }); },
|
||||||
|
500);
|
||||||
xhr.addEventListener('progress', loading);
|
xhr.addEventListener('progress', loading);
|
||||||
xhr.addEventListener('loaded', loading);
|
xhr.addEventListener('loadend', function (evt) {
|
||||||
|
loading(evt);
|
||||||
|
clearInterval(id);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
xhr.addEventListener('error', error);
|
xhr.addEventListener('error', error);
|
||||||
xhr.addEventListener('load', function (ref) {
|
xhr.addEventListener('load', function (ref) {
|
||||||
@ -2466,8 +2471,9 @@ function renderSidebar (content) {
|
|||||||
function renderLoading (ref) {
|
function renderLoading (ref) {
|
||||||
var loaded = ref.loaded;
|
var loaded = ref.loaded;
|
||||||
var total = ref.total;
|
var total = ref.total;
|
||||||
|
var step = ref.step;
|
||||||
|
|
||||||
var num = Math.floor(loaded / total * 100);
|
var num;
|
||||||
|
|
||||||
if (!CACHE.loading) {
|
if (!CACHE.loading) {
|
||||||
var div = document.createElement('div');
|
var div = document.createElement('div');
|
||||||
@ -2476,13 +2482,19 @@ function renderLoading (ref) {
|
|||||||
document.body.appendChild(div);
|
document.body.appendChild(div);
|
||||||
CACHE.loading = div;
|
CACHE.loading = div;
|
||||||
}
|
}
|
||||||
|
if (step) {
|
||||||
|
num = parseInt(CACHE.loading.style.width, 10) + step;
|
||||||
|
num = num > 80 ? 80 : num;
|
||||||
|
} else {
|
||||||
|
num = Math.floor(loaded / total * 100);
|
||||||
|
}
|
||||||
|
|
||||||
CACHE.loading.style.opacity = 1;
|
CACHE.loading.style.opacity = 1;
|
||||||
CACHE.loading.style.width = num >= 95 ? '100%' : num + '%';
|
CACHE.loading.style.width = num >= 95 ? '100%' : num + '%';
|
||||||
|
|
||||||
if (num >= 95) {
|
if (num >= 95) {
|
||||||
clearTimeout(renderLoading.cacheTImeout);
|
clearTimeout(renderLoading.cacheTimeout);
|
||||||
renderLoading.cacheTImeout = setTimeout(function (_) {
|
renderLoading.cacheTimeout = setTimeout(function (_) {
|
||||||
CACHE.loading.style.opacity = 0;
|
CACHE.loading.style.opacity = 0;
|
||||||
CACHE.loading.style.width = '0%';
|
CACHE.loading.style.width = '0%';
|
||||||
}, 200);
|
}, 200);
|
||||||
|
4
lib/docsify.min.js
vendored
4
lib/docsify.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user