From e58c17fdc640d3c066ee7f51594f8152be133899 Mon Sep 17 00:00:00 2001 From: "qingwei.li" Date: Sat, 17 Dec 2016 09:01:21 +0800 Subject: [PATCH 1/3] Optimize progress bar --- CHANGELOG.md | 4 ++++ src/render.js | 11 ++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5131f2558..eba4cdf6a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.1.1 +### Bug fixes +- Optimize progress bar + ## 1.1.0 ## Features - Add progress bar diff --git a/src/render.js b/src/render.js index e94cd0331..c85f93625 100644 --- a/src/render.js +++ b/src/render.js @@ -122,7 +122,16 @@ export function renderLoading ({ loaded, total }) { document.body.appendChild(div) CACHE['loading'] = div } - CACHE['loading'].style.width = num >= 95 ? '0%' : num + '%' + + 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) + } } /** From 14a4c2f77da0c5daa0797370a49d9149e853fa91 Mon Sep 17 00:00:00 2001 From: "qingwei.li" Date: Sat, 17 Dec 2016 09:01:41 +0800 Subject: [PATCH 2/3] bump 1.1.1 --- lib/docsify.js | 11 ++++++++++- lib/docsify.min.js | 4 ++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/docsify.js b/lib/docsify.js index 487c5f2b2..63a606940 100644 --- a/lib/docsify.js +++ b/lib/docsify.js @@ -2467,7 +2467,16 @@ function renderLoading (ref) { document.body.appendChild(div); CACHE['loading'] = div; } - CACHE['loading'].style.width = num >= 95 ? '0%' : num + '%'; + + CACHE['loading'].style.opacity = 1; + CACHE['loading'].style.width = num + '%'; + if (num >= 95) { + clearTimeout(renderLoading.cacheTImeout); + renderLoading.cacheTImeout = setTimeout(function (_) { + CACHE['loading'].style.opacity = 0; + CACHE['loading'].style.width = '0%'; + }, 200); + } } /** diff --git a/lib/docsify.min.js b/lib/docsify.min.js index dddb05610..e8a267f20 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(S===e.hash&&!r(w))return w;var t=e.hash.match(/^#\/([^#]+)/);return t=t&&2===t.length?t[1]:/^#\//.test(e.hash)?"":e.pathname,w=t,S=e.hash,t}function a(){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(!/mobile/i.test(navigator.userAgent)){for(var t=document.querySelectorAll(".anchor"),n={},r=document.querySelectorAll(".sidebar li"),i=null,a=0,s=r.length;a\n \n '):""}function g(){return'
\n \n
\n
\n
\n
'}function h(e){return e?'':""}function d(e,t){return void 0===t&&(t=""),e&&e.length?(e.forEach(function(e){t+='
  • '+e.title+"
  • ",e.children&&(t+='
    • '+d(e.children)+"
    ")}),t):""}function f(e,t){var n=document.querySelector("nav")||document.createElement("nav");e[t?"outerHTML":"innerHTML"]=h(A.sidebarToggle)+p(A.repo)+g(),document.body.insertBefore(n,document.body.children[0]),l("button.sidebar-toggle")}function m(e){E("article",e?L(e):"not found"),y.rendered||y(null,A),b.rendered||b(null,A),y.rendered=!1,b.rendered=!1,A.auto2top&&u("section.content")}function b(e){$.navbar&&$.navbar===e||($.navbar=e,b.rendered=!0,e&&E("nav",L(e)),o("nav"))}function y(e){var n=!1;e?e=L(e):A.sidebar?e=d(A.sidebar,"