bump: 3.0.3

This commit is contained in:
qingwei.li 2017-02-19 22:52:59 +08:00
commit 066fff4beb
8 changed files with 70 additions and 63 deletions

View file

@ -213,11 +213,11 @@ function on (el, type, handler) {
: el.addEventListener(type, handler);
}
var off = function on (el, type, handler) {
function off (el, type, handler) {
isFn(type)
? window.removeEventListener(el, type)
: el.removeEventListener(type, handler);
};
}
/**
* Toggle class
@ -464,17 +464,62 @@ function getAndActive (el, isParent, autoTitle) {
return target
}
var nav = {};
var hoverOver = false;
function highlight () {
var sidebar = getNode('.sidebar');
var anchors = findAll('.anchor');
var wrap = find(sidebar, '.sidebar-nav');
var active = find(sidebar, 'li.active');
var top = body.scrollTop;
var last;
for (var i = 0, len = anchors.length; i < len; i += 1) {
var node = anchors[i];
if (node.offsetTop > top) {
if (!last) { last = node; }
break
} else {
last = node;
}
}
if (!last) { return }
var li = nav[last.getAttribute('data-id')];
if (!li || li === active) { return }
active && active.classList.remove('active');
li.classList.add('active');
active = li;
// scroll into view
// https://github.com/vuejs/vuejs.org/blob/master/themes/vue/source/js/common.js#L282-L297
if (!hoverOver && body.classList.contains('sticky')) {
var height = sidebar.clientHeight;
var curOffset = 0;
var cur = active.offsetTop + active.clientHeight + 40;
var isInView = (
active.offsetTop >= wrap.scrollTop &&
cur <= wrap.scrollTop + height
);
var notThan = cur - curOffset < height;
var top$1 = isInView
? wrap.scrollTop
: notThan
? curOffset
: cur - height;
sidebar.scrollTop = top$1;
}
}
function scrollActiveSidebar () {
if (isMobile) { return }
var hoverOver = false;
var anchors = findAll('.anchor');
var sidebar = find('.sidebar');
var wrap = find(sidebar, '.sidebar-nav');
var nav = {};
var sidebar = getNode('.sidebar');
var lis = findAll(sidebar, 'li');
var active = find(sidebar, 'li.active');
for (var i = 0, len = lis.length; i < len; i += 1) {
var li = lis[i];
@ -489,50 +534,6 @@ function scrollActiveSidebar () {
nav[decodeURIComponent(href)] = li;
}
function highlight () {
var top = body.scrollTop;
var last;
for (var i = 0, len = anchors.length; i < len; i += 1) {
var node = anchors[i];
if (node.offsetTop > top) {
if (!last) { last = node; }
break
} else {
last = node;
}
}
if (!last) { return }
var li = nav[last.getAttribute('data-id')];
if (!li || li === active) { return }
active && active.classList.remove('active');
li.classList.add('active');
active = li;
// scroll into view
// https://github.com/vuejs/vuejs.org/blob/master/themes/vue/source/js/common.js#L282-L297
if (!hoverOver && body.classList.contains('sticky')) {
var height = sidebar.clientHeight;
var curOffset = 0;
var cur = active.offsetTop + active.clientHeight + 40;
var isInView = (
active.offsetTop >= wrap.scrollTop &&
cur <= wrap.scrollTop + height
);
var notThan = cur - curOffset < height;
var top$1 = isInView
? wrap.scrollTop
: notThan
? curOffset
: cur - height;
sidebar.scrollTop = top$1;
}
}
off('scroll', highlight);
on('scroll', highlight);
on(sidebar, 'mouseover', function () { hoverOver = true; });
@ -3108,10 +3109,12 @@ function renderMain (html) {
// execute script
this.config.executeScript && executeScript();
if (!this.config.executeScript &&
if (this.config.executeScript !== false &&
typeof window.Vue !== 'undefined' &&
!executeScript()) {
setTimeout(function (_) {
var vueVM = window.__EXECUTE_RESULT__;
vueVM && vueVM.$destroy && vueVM.$destroy();
window.__EXECUTE_RESULT__ = new window.Vue().$mount('#main');
}, 0);
}
@ -3449,7 +3452,6 @@ initGlobalAPI();
/**
* Run Docsify
*/
setTimeout(function (_) { return new Docsify(); }, 0);
}());

4
lib/docsify.min.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long