mirror of
https://github.com/ant-design/ant-design.git
synced 2025-01-18 14:13:37 +08:00
fix home page
This commit is contained in:
parent
8be1ffdfe0
commit
00df19d3e3
@ -58,39 +58,39 @@ InstantClickChangeFns.push(function() {
|
|||||||
$('.markdown #api').nextAll().andSelf().appendTo('.api-container');
|
$('.markdown #api').nextAll().andSelf().appendTo('.api-container');
|
||||||
|
|
||||||
// 滚动时固定锚点、高亮当前项
|
// 滚动时固定锚点、高亮当前项
|
||||||
var titles = $('.markdown :header:not(h1)');
|
if ($('.toc')[0]) {
|
||||||
var doc = $(document);
|
var titles = $('.markdown :header:not(h1)');
|
||||||
var tocTop = $('.toc').offset().top;
|
var doc = $(document);
|
||||||
function onScroll() {
|
var tocTop = $('.toc').offset().top;
|
||||||
var top = doc.scrollTop(), i;
|
function onScroll() {
|
||||||
if (top >= doc.height()- $(window).height() - 20) {
|
var top = doc.scrollTop(), i;
|
||||||
i = titles.length - 1;
|
if (top >= doc.height()- $(window).height() - 20) {
|
||||||
} else {
|
i = titles.length - 1;
|
||||||
for (i=0; i<titles.length; i++) {
|
} else {
|
||||||
if (top < titles.eq(i).offset().top - 20) {
|
for (i=0; i<titles.length; i++) {
|
||||||
break;
|
if (top < titles.eq(i).offset().top - 20) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
i--;
|
||||||
|
i = (i < 0) ? 0 : i;
|
||||||
|
i = (i > titles.length - 1) ? (titles.length - 1) : i;
|
||||||
}
|
}
|
||||||
i--;
|
$('.anchor a').removeClass('current');
|
||||||
i = (i < 0) ? 0 : i;
|
$('.anchor a').eq(i).addClass('current');
|
||||||
i = (i > titles.length - 1) ? (titles.length - 1) : i;
|
|
||||||
}
|
|
||||||
$('.anchor a').removeClass('current');
|
|
||||||
$('.anchor a').eq(i).addClass('current');
|
|
||||||
|
|
||||||
if (top >= tocTop) {
|
if (top >= tocTop) {
|
||||||
$('.toc').addClass('sticky');
|
$('.toc').addClass('sticky');
|
||||||
} else {
|
} else {
|
||||||
$('.toc').removeClass('sticky');
|
$('.toc').removeClass('sticky');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
onScroll();
|
||||||
|
// 滚动高亮
|
||||||
|
$(window).off('scroll');
|
||||||
|
$(window).on('scroll', onScroll);
|
||||||
}
|
}
|
||||||
|
|
||||||
onScroll();
|
|
||||||
|
|
||||||
// 滚动高亮
|
|
||||||
$(window).off('scroll');
|
|
||||||
$(window).on('scroll', onScroll);
|
|
||||||
|
|
||||||
// 添加上一页下一页
|
// 添加上一页下一页
|
||||||
if ($('.aside-container li > a').length > 0) {
|
if ($('.aside-container li > a').length > 0) {
|
||||||
var links = $('.aside-container li > a');
|
var links = $('.aside-container li > a');
|
||||||
|
Loading…
Reference in New Issue
Block a user