diff --git a/CHANGELOG.md b/CHANGELOG.md index 4553f687e..dd97febd0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.1.3 +### Bug fixes +- Optimize progress bar again + ## 1.1.2 ### Bug fixes - fix failed `auto2top` in mobile diff --git a/README.md b/README.md index 055c0f444..6daf80296 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,9 @@ Create a `404.html` and `README.md` into `/docs`. - + +
+ ``` @@ -41,7 +43,9 @@ index.html - + +
+ ``` diff --git a/lib/docsify.js b/lib/docsify.js index 2dbcdf1cc..2b0149660 100644 --- a/lib/docsify.js +++ b/lib/docsify.js @@ -2426,8 +2426,8 @@ function renderArticle (content) { * navbar */ function renderNavbar (content) { - if (CACHE['navbar'] && CACHE['navbar'] === content) { return } - CACHE['navbar'] = content; + if (CACHE.navbar && CACHE.navbar === content) { return } + CACHE.navbar = content; renderNavbar.rendered = true; if (content) { renderTo('nav', marked(content)); } @@ -2450,8 +2450,8 @@ function renderSidebar (content) { } renderSidebar.rendered = true; - if (CACHE['sidebar'] && CACHE['sidebar'] === content) { return } - CACHE['sidebar'] = content; + if (CACHE.sidebar && CACHE.sidebar === content) { return } + CACHE.sidebar = content; renderTo('aside.sidebar', content); if (isToc) { scrollActiveSidebar(); } toc = []; @@ -2467,24 +2467,23 @@ function renderLoading (ref) { var num = Math.floor(loaded / total * 100); - if (!CACHE['loading']) { + if (!CACHE.loading) { var div = document.createElement('div'); div.classList.add('progress'); document.body.appendChild(div); - CACHE['loading'] = div; + CACHE.loading = div; } + CACHE.loading.style.opacity = 1; + CACHE.loading.style.width = num >= 95 ? '100%' : num + '%'; + if (num >= 95) { clearTimeout(renderLoading.cacheTImeout); - CACHE['loading'].style.width = '100%'; renderLoading.cacheTImeout = setTimeout(function (_) { - CACHE['loading'].style.opacity = 0; - CACHE['loading'].style.width = '0%'; + CACHE.loading.style.opacity = 0; + CACHE.loading.style.width = '0%'; }, 200); - } else { - CACHE['loading'].style.opacity = 1; - CACHE['loading'].style.width = num + '%'; } } diff --git a/lib/docsify.min.js b/lib/docsify.min.js index 147e52982..b82a1c8cd 100644 --- a/lib/docsify.min.js +++ b/lib/docsify.min.js @@ -1,2 +1,2 @@ -var Docsify=function(){"use strict";function e(e,t,n){void 0===t&&(t="GET");var r=new XMLHttpRequest;return r.open(t,e),r.send(),{then:function(e,t){void 0===t&&(t=function(){}),n&&(r.addEventListener("progress",n),r.addEventListener("loaded",n)),r.addEventListener("error",t),r.addEventListener("load",function(n){var r=n.target;r.status>=400?t(r):e(r.response)})},abort:function(){return 4!==r.readyState&&r.abort()}}}function t(e,t){var n=[],r={};return e.forEach(function(e){var i=e.level||1,a=i-1;i>t||(r[a]?(r[a].children=r[a].children||[],r[a].children.push(e)):n.push(e),r[i]=e)}),n}function n(e){return e.replace(/([A-Z])/g,function(e){return"-"+e.toLowerCase()})}function r(e){return null===e||void 0===e}function i(){var e=window.location;if(_===e.hash&&!r(S))return S;var t=e.hash.match(/^#\/([^#]+)/);return t=t&&2===t.length?t[1]:/^#\//.test(e.hash)?"":e.pathname,S=t,_=e.hash,t}function a(){return/mobile/i.test(navigator.userAgent)}function s(){function e(){for(var e=0,r=t.length;e10){var o=n[a.id];if(!o||o===i)return;return i&&i.setAttribute("class",""),o.setAttribute("class","active"),void(i=o)}}}if(!a()){for(var t=document.querySelectorAll(".anchor"),n={},r=document.querySelectorAll(".sidebar li"),i=null,s=0,o=r.length;s\n \n '):""}function h(){return'
\n \n
\n
\n
\n
'}function d(e){return e?'':""}function f(e,t){return void 0===t&&(t=""),e&&e.length?(e.forEach(function(e){t+='
  • '+e.title+"
  • ",e.children&&(t+='
    • '+f(e.children)+"
    ")}),t):""}function m(e,t){var n=document.querySelector("nav")||document.createElement("nav");e[t?"outerHTML":"innerHTML"]=d($.sidebarToggle)+g($.repo)+h(),document.body.insertBefore(n,document.body.children[0]),u("button.sidebar-toggle")}function b(e){q("article",e?C(e):"not found"),k.rendered||k(null,$),y.rendered||y(null,$),k.rendered=!1,y.rendered=!1,$.auto2top&&c()}function y(e){E.navbar&&E.navbar===e||(E.navbar=e,y.rendered=!0,e&&q("nav",C(e)),l("nav"))}function k(e){var n=!1;e?e=C(e):$.sidebar?e=f($.sidebar,"