Commit 86471716 authored by Liyuan Li's avatar Liyuan Li

🐛 fix #100

parent 7ce1bc9c
......@@ -13,7 +13,7 @@
* @fileoverview util and every page should be used.
*
* @author <a href="http://vanessa.b3log.org">Liyuan Li</a>
* @version 1.0.0.0, Jan 18, 2019
* @version 1.0.1.0, Apr 11, 2020
*/
import '../../../js/common'
......@@ -118,8 +118,9 @@ window.Skin = {
$('.post__toc').slideToggle()
})
}
var $articleTocs = $('.vditor-reset [id^=toc_h]')
var $articleTocs = $('.vditor-reset.article__content').children().filter((index, item) => {
return item.tagName.indexOf('H') === 0 && item.id
})
var $articleToc = $('.article__toc')
$articleToc.find('a').click(function (event) {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -13,7 +13,7 @@
* @fileoverview util and every page should be used.
*
* @author <a href="http://vanessa.b3log.org">Liyuan Li</a>
* @version 1.0.0.0, Jan 18, 2019
* @version 1.0.1.0, Apr 11, 2020
*/
import '../../../js/common'
......@@ -53,7 +53,9 @@ window.Skin = {
initArticle: function () {
page.share()
var $articleTocs = $('.vditor-reset [id^=toc_h]')
var $articleTocs = $('.vditor-reset.item__content--article').children().filter((index, item) => {
return item.tagName.indexOf('H') === 0 && item.id
})
var $articleToc = $('.article__toc')
var $articleProgress = $('.article__progress')
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -13,7 +13,7 @@
* @fileoverview util and every page should be used.
*
* @author <a href="http://vanessa.b3log.org">Liyuan Li</a>
* @version 1.0.0.0, Jan 18, 2019
* @version 1.0.1.0, Apr 11, 2020
*/
import '../../../js/common'
......@@ -77,8 +77,12 @@ window.Skin = {
$('.post__toc').
css('left', $('.post').offset().left + $('.post').outerWidth())
var $articleTocs = $('.vditor-reset [id^=toc_h]'),
$articleToc = $('.article__toc')
var $articleTocs = $('.post .vditor-reset').
children().
filter((index, item) => {
return item.tagName.indexOf('H') === 0 && item.id
})
var $articleToc = $('.article__toc')
$(window).unbind('scroll').scroll(function (event) {
if ($('.article__toc li').length === 0) {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -13,10 +13,11 @@
* @fileoverview util and every page should be used.
*
* @author <a href="http://vanessa.b3log.org">Liyuan Li</a>
* @version 1.0.0.0, Jan 18, 2019
* @version 1.0.1.0, Apr 11, 2020
*/
import '../../../js/common'
/**
* @description next 皮肤脚本
* @static
......@@ -24,110 +25,116 @@ import '../../../js/common'
window.NexT = {
init: function () {
$('.sidebar-toggle').click(function () {
var $sidebar = $('.sidebar');
var $sidebar = $('.sidebar')
if ($(this).hasClass('sidebar-active')) {
$(this).removeClass('sidebar-active');
$(this).removeClass('sidebar-active')
$('body').animate({
'padding-right': 0
});
'padding-right': 0,
})
$sidebar.animate({
right: -320
});
$sidebar.find('section').css('opacity', 0);
right: -320,
})
$sidebar.find('section').css('opacity', 0)
} else {
$(this).addClass('sidebar-active');
$(this).addClass('sidebar-active')
$('body').animate({
'padding-right': 320
});
'padding-right': 320,
})
$sidebar.animate({
right: 0
right: 0,
}, function () {
$sidebar.find('section:first').animate({
'opacity': 1
});
});
'opacity': 1,
})
})
}
});
})
$('.site-nav-toggle').click(function () {
$('.site-nav').slideToggle();
});
$('.site-nav').slideToggle()
})
$(document).ready(function () {
setTimeout(function () {
// logo animate
$('.logo-wrap').css('opacity', 1);
$('.logo-wrap').css('opacity', 1)
$('.logo-line-before i').animate({
'left': '0'
'left': '0',
}, function () {
$('.site-title').css('opacity', 1).animate({
'top': 0
'top': 0,
}, function () {
$('.menu').css('opacity', 1).animate({
'margin-top': '15px'
});
'margin-top': '15px',
})
$('.main').css('opacity', 1).animate({
'top': '0'
'top': '0',
}, function () {
// 当有文章页面有目录时,回调不放这里,侧边栏就会一片空白
if ($('.article__toc li').length > 0 && $(window).width() > 1000) {
$('.sidebar-toggle').click();
if ($('.article__toc li').length > 0 && $(window).width() >
1000) {
$('.sidebar-toggle').click()
}
});
});
})
})
});
})
$('.logo-line-after i').animate({
'right': '0'
});
}, 500);
});
'right': '0',
})
}, 500)
})
},
initArticle: function () {
if ($('.article__toc li').length > 0 && $(window).width() > 1000) {
// add color to sidebar menu
$('.sidebar-toggle').addClass('has-toc');
this.initToc();
$('.sidebar-toggle').addClass('has-toc')
this.initToc()
}
},
initToc: function () {
var $articleTocs = $('.vditor-reset [id^=toc_h]'),
$articleToc = $('.article__toc');
var $articleTocs = $('.vditor-reset.post-body--article').
children().
filter((index, item) => {
return item.tagName.indexOf('H') === 0 && item.id
})
var $articleToc = $('.article__toc')
$(window).scroll(function (event) {
if ($('.article__toc li').length === 0) {
return false;
return false
}
// 界面各种图片加载会导致帖子目录定位
var toc = [];
var toc = []
$articleTocs.each(function (i) {
toc.push({
id: this.id,
offsetTop: this.offsetTop
});
});
offsetTop: this.offsetTop,
})
})
// 当前目录样式
var scrollTop = $(window).scrollTop();
var scrollTop = $(window).scrollTop()
for (var i = 0, iMax = toc.length; i < iMax; i++) {
if (scrollTop < toc[i].offsetTop + 200) {
$articleToc.find('li').removeClass('current');
var index = i > 0 ? i - 1 : 0;
$articleToc.find('a[href="#' + toc[index].id + '"]').parent().addClass('current');
break;
$articleToc.find('li').removeClass('current')
var index = i > 0 ? i - 1 : 0
$articleToc.find('a[href="#' + toc[index].id + '"]').
parent().
addClass('current')
break
}
}
if (scrollTop >= toc[toc.length - 1].offsetTop + 200) {
$articleToc.find('li').removeClass('current');
$articleToc.find('li:last').addClass('current');
$articleToc.find('li').removeClass('current')
$articleToc.find('li:last').addClass('current')
}
});
})
$(window).scroll();
}
};
NexT.init();
$(window).scroll()
},
}
NexT.init()
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment