Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
大白技术控
yanglr2010
提交
a314dc03
Y
yanglr2010
项目概览
大白技术控
/
yanglr2010
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Y
yanglr2010
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
a314dc03
编写于
3月 13, 2020
作者:
EvanOne(文一)
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: Toc highlighting is incorrect
上级
0026d9d6
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
6 addition
and
9 deletion
+6
-9
source/js/sidebar.js
source/js/sidebar.js
+6
-9
未找到文件。
source/js/sidebar.js
浏览文件 @
a314dc03
...
@@ -18,7 +18,7 @@ $(document).ready(function () {
...
@@ -18,7 +18,7 @@ $(document).ready(function () {
var
currHeading
=
null
;
var
currHeading
=
null
;
// The heading that reached the top last time.
// The heading that reached the top last time.
var
lastHeading
=
null
;
var
lastHeading
=
null
;
var
isRemoveTocClass
=
false
;
var
isRemove
d
TocClass
=
false
;
// Automatically expand items in the article directory
// Automatically expand items in the article directory
// based on the scrolling of heading in the article.
// based on the scrolling of heading in the article.
...
@@ -43,25 +43,22 @@ $(document).ready(function () {
...
@@ -43,25 +43,22 @@ $(document).ready(function () {
if
(
if
(
$postBody
[
0
]
&&
$postBody
[
0
]
&&
$firsetChild
[
0
]
&&
$firsetChild
[
0
]
&&
$firsetChild
[
0
].
getBoundingClientRect
().
top
>
0
&&
$firsetChild
.
offset
().
top
-
$
(
window
).
scrollTop
()
>
0
$firsetChild
.
offset
().
top
-
$
(
window
).
scrollTop
()
>
0
)
{
)
{
if
(
!
isRemoveTocClass
)
{
if
(
!
isRemove
d
TocClass
)
{
$allTocItem
.
removeClass
(
'
active current
'
);
$allTocItem
.
removeClass
(
'
active current
'
);
isRemoveTocClass
=
true
;
isRemove
d
TocClass
=
true
;
}
}
return
;
return
;
}
}
if
(
currHeading
!==
lastHeading
)
{
if
(
currHeading
!==
lastHeading
)
{
var
$targetLink
=
$
(
'
.sidebar-toc a[href="#
'
+
currHeading
+
'
"]
'
);
var
$targetLink
=
$
(
'
.sidebar-toc a[href="#
'
+
currHeading
+
'
"]
'
);
// If the relevant "<a>" is not found, remain the state of the toc,
$allTocItem
.
removeClass
(
'
active current
'
);
// either, remove styles for all active states.
if
(
$targetLink
[
0
])
{
$allTocItem
.
removeClass
(
'
active current
'
);
}
$targetLink
.
parents
(
'
li
'
).
addClass
(
'
active
'
);
$targetLink
.
parents
(
'
li
'
).
addClass
(
'
active
'
);
$targetLink
.
parent
().
addClass
(
'
current
'
);
$targetLink
.
parent
().
addClass
(
'
current
'
);
lastHeading
=
currHeading
;
lastHeading
=
currHeading
;
isRemovedTocClass
=
false
;
}
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录