bump 1.1.7

This commit is contained in:
qingwei.li 2016-12-19 21:53:25 +08:00
parent 73a193d602
commit 48912a0b79
2 changed files with 18 additions and 6 deletions

View File

@ -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

File diff suppressed because one or more lines are too long