From 90b490c9c1f69b6c9cf61b1961f173c2e0083594 Mon Sep 17 00:00:00 2001 From: "qingwei.li" Date: Tue, 10 Jan 2017 23:48:12 +0800 Subject: [PATCH 1/3] Fixed sidebar bug when the coverpage exist --- CHANGELOG.md | 4 ++++ src/event.js | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 86321d313..1db406fff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.6.1 +### Bug fixes +- Fixed sidebar bug when the coverpage exist + ## 1.6.0 ### Features - Improve sidebar performance. The active item is automatically scrolled in the visible view. diff --git a/src/event.js b/src/event.js index 0bfe51468..8028127ce 100644 --- a/src/event.js +++ b/src/event.js @@ -48,7 +48,7 @@ export function scrollActiveSidebar () { li.classList.add('active') active = li - !hoveredOverSidebar && active.scrollIntoView() + !hoveredOverSidebar && sticky.isSticky && active.scrollIntoView() } window.removeEventListener('scroll', highlight) @@ -125,8 +125,10 @@ export function sticky () { return (function () { if (window.pageYOffset >= coverHeight || dom.classList.contains('hidden')) { document.body.classList.add('sticky') + sticky.isSticky = true } else { document.body.classList.remove('sticky') + sticky.isSticky = false } })() } From a418096a29596c1c5776ab92a07b68f62e5831e3 Mon Sep 17 00:00:00 2001 From: "qingwei.li" Date: Tue, 10 Jan 2017 23:48:49 +0800 Subject: [PATCH 2/3] bump 1.6.1 --- lib/docsify.js | 4 +++- lib/docsify.min.js | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/docsify.js b/lib/docsify.js index 47a0f15e9..f8ba79566 100644 --- a/lib/docsify.js +++ b/lib/docsify.js @@ -216,7 +216,7 @@ function scrollActiveSidebar () { li.classList.add('active'); active = li; - !hoveredOverSidebar && active.scrollIntoView(); + !hoveredOverSidebar && sticky.isSticky && active.scrollIntoView(); } window.removeEventListener('scroll', highlight); @@ -293,8 +293,10 @@ function sticky () { return (function () { if (window.pageYOffset >= coverHeight || dom.classList.contains('hidden')) { document.body.classList.add('sticky'); + sticky.isSticky = true; } else { document.body.classList.remove('sticky'); + sticky.isSticky = false; } })() } diff --git a/lib/docsify.min.js b/lib/docsify.min.js index 819acab21..73b48db92 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){if(void 0===t&&(t=function(){}),n){var a=setInterval(function(e){return n({step:Math.floor(5*Math.random()+1)})},500);r.addEventListener("progress",n),r.addEventListener("loadend",function(e){n(e),clearInterval(a)})}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 a=e.level||1,i=a-1;a>t||(r[i]?(r[i].children=r[i].children||[],r[i].children.push(e)):n.push(e),r[a]=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 a(){var e=window.location;if(E===e.hash&&!r($))return $;var t=e.hash.match(/^#\/([^#]+)/);return t=t&&2===t.length?t[1]:/^#\//.test(e.hash)?"":e.pathname,$=t,E=e.hash,t}function i(){return document.body.clientWidth<=600}function s(e){var t=/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,.\/:;<=>?@\[\]^`{|}~]/g,n=!1,r="-";if(s.occurrences=s.occurrences||{},"string"!=typeof e)return"";n||(e=e.toLowerCase());var a=e.trim().replace(/<[^>\d]+>/g,"").replace(t,"").replace(/\s/g,r).replace(/-+/g,r).replace(/^(\d)/,"_$1"),i=s.occurrences[a];return s.occurrences.hasOwnProperty(a)?i++:i=0,s.occurrences[a]=i,i&&(a=a+"-"+i),a}function o(){function e(){for(var e,r=document.body.scrollTop,i=0,s=n.length;ir){e||(e=l);break}e=l}if(e){var u=a[e.getAttribute("data-id")];u&&u!==o&&(o&&o.classList.remove("active"),u.classList.add("active"),o=u,!t&&o.scrollIntoView())}}if(!i()){for(var t=!1,n=document.querySelectorAll(".anchor"),r=document.querySelector("aside.sidebar"),a={},s=r.querySelectorAll("li"),o=r.querySelector("li.active"),l=0,u=s.length;l=t||e.classList.contains("hidden")?document.body.classList.add("sticky"):document.body.classList.remove("sticky")}()}function g(e,t){return t={exports:{}},e(t,t.exports),t.exports}function h(e){return e?(/\/\//.test(e)||(e="https://github.com/"+e),e=e.replace(/^git\+/,""),'\n \n \n '):""}function f(e){var t=e+'';return(i()?t+"
":"
"+t)+'
\n
\n
\n
'}function m(){var e=", 100%, 85%",t="linear-gradient(to left bottom, hsl("+(Math.floor(255*Math.random())+e)+") 0%, hsl("+(Math.floor(255*Math.random())+e)+") 100%)";return'
\n
\n
\n
'}function b(){return''}function v(e,t){return void 0===t&&(t=""),e&&e.length?(e.forEach(function(e){t+='
  • '+e.title+"
  • ",e.children&&(t+='
    • '+v(e.children)+"
    ")}),t):""}function y(e){M=e;var t=new j.Renderer;t.heading=function(e,t){var n=s(e),r="";return M.router&&(r="#/"+a()),P.push({level:t,slug:r+"#"+encodeURIComponent(n),title:e}),"'+e+""},t.code=function(e,t){void 0===t&&(t="");var n=O.highlight(e,O.languages[t]||O.languages.markup).replace(/{{/g,"{{");return'
    '+n+"
    "},t.link=function(e,t,n){return M.router&&!/:/.test(e)&&(e=("#/"+e).replace(/\/\//g,"/")),''+n+""},t.paragraph=function(e){var t=W.test(e);return t?'

    '+e.replace(W,"")+"

    ":"

    "+e+"

    "},"function"==typeof M.markdown?(N.setOptions({renderer:t}),N=M.markdown.call(this,N)):N.setOptions(q({renderer:t},M.markdown))}function k(e,t){var n=document.querySelector("nav")||document.createElement("nav");M.repo||n.classList.add("no-badge"),e[t?"outerHTML":"innerHTML"]=h(M.repo)+(M.coverpage?m():"")+f(M.sidebarToggle?b():""),document.body.insertBefore(n,document.body.children[0]),c("button.sidebar-toggle"),M.coverpage?!i()&&window.addEventListener("scroll",d):document.body.classList.add("sticky")}function x(e){if(F("article",e?N(e):"not found"),M.sidebar||M.loadSidebar||L(),e&&"undefined"!=typeof Vue&&"undefined"!=typeof Vuep){var t=new Vue({el:"main"});t.$nextTick(function(e){return o()})}M.auto2top&&setTimeout(function(){return p(M.auto2top)},0)}function w(e){I.navbar&&I.navbar===e||(I.navbar=e,e&&F("nav",N(e)),u("nav"))}function L(e){var n;n=e?N(e):M.sidebar?v(M.sidebar,"