Skip to content

Commit 8a9867e

Browse files
committed
Bug: toc disappears after clicking on a toc item and toggling sidebar. #235, #261
1 parent d02ad36 commit 8a9867e

File tree

4 files changed

+99
-93
lines changed

4 files changed

+99
-93
lines changed

.jshintrc

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
"strict": false,
1414

1515
"globals": {
16-
"module": true
16+
"$": true,
17+
"window": true,
18+
"document": true
1719
}
1820
}

_config.yml

+85-85
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,85 @@
1-
# when running hexo in a subdirectory (e.g. domain.tld/blog), remove leading slashes ( "/archives" -> "archives" )
2-
menu:
3-
home: /
4-
#categories: /categories
5-
#about: /about
6-
archives: /archives
7-
tags: /tags
8-
#commonweal: /404.html
9-
10-
# Place your favicon.ico to /source directory.
11-
favicon: /favicon.ico
12-
13-
# Set default keywords (Use a comma to separate)
14-
keywords: "Hexo,next"
15-
16-
# Set rss to false to disable feed link.
17-
# Leave rss as empty to use site's feed link.
18-
# Set rss to specific value if you have burned your feed already.
19-
rss:
20-
21-
# Icon fonts
22-
# Place your font into next/source/fonts, specify directory-name and font-name here
23-
# Avialable: default | linecons | fifty-shades | feather
24-
icon_font: default
25-
#icon_font: fifty-shades
26-
#icon_font: feather
27-
#icon_font: linecons
28-
29-
# Code Highlight theme
30-
# Available value: normal | night | night eighties | night blue | night bright
31-
# https://github.com/chriskempson/tomorrow-theme
32-
highlight_theme: normal
33-
34-
35-
# MathJax Support
36-
mathjax:
37-
38-
39-
# Schemes
40-
#scheme: Mist
41-
42-
43-
# Sidebar, available value:
44-
# - post expand on posts automatically. Default.
45-
# - always expand for all pages automatically
46-
# - hide expand only when click on the sidebar toggle icon.
47-
sidebar: post
48-
#sidebar: always
49-
#sidebar: hide
50-
51-
52-
# Automatically scroll page to section which is under <!-- more --> mark.
53-
scroll_to_more: true
54-
55-
56-
# Automatically add list number to toc.
57-
toc_list_number: true
58-
59-
# Automatically Excerpt
60-
auto_excerpt:
61-
enable: false
62-
length: 150
63-
64-
# Use Lato font
65-
# Note: this option is avialable only when the language is not `zh-Hans`
66-
use_font_lato: true
67-
68-
69-
## DO NOT EDIT THE FOLLOWING SETTINGS
70-
## UNLESS YOU KNOW WHAT YOU ARE DOING
71-
72-
# Use velocity to animate everything.
73-
use_motion: true
74-
75-
# Fancybox
76-
fancybox: true
77-
78-
# Static files
79-
vendors: vendors
80-
css: css
81-
js: js
82-
images: images
83-
84-
# Theme version
85-
version: 0.4.3
1+
# when running hexo in a subdirectory (e.g. domain.tld/blog), remove leading slashes ( "/archives" -> "archives" )
2+
menu:
3+
home: /
4+
#categories: /categories
5+
#about: /about
6+
archives: /archives
7+
tags: /tags
8+
#commonweal: /404.html
9+
10+
# Place your favicon.ico to /source directory.
11+
favicon: /favicon.ico
12+
13+
# Set default keywords (Use a comma to separate)
14+
keywords: "Hexo,next"
15+
16+
# Set rss to false to disable feed link.
17+
# Leave rss as empty to use site's feed link.
18+
# Set rss to specific value if you have burned your feed already.
19+
rss:
20+
21+
# Icon fonts
22+
# Place your font into next/source/fonts, specify directory-name and font-name here
23+
# Avialable: default | linecons | fifty-shades | feather
24+
icon_font: default
25+
#icon_font: fifty-shades
26+
#icon_font: feather
27+
#icon_font: linecons
28+
29+
# Code Highlight theme
30+
# Available value: normal | night | night eighties | night blue | night bright
31+
# https://github.com/chriskempson/tomorrow-theme
32+
highlight_theme: normal
33+
34+
35+
# MathJax Support
36+
mathjax:
37+
38+
39+
# Schemes
40+
#scheme: Mist
41+
42+
43+
# Sidebar, available value:
44+
# - post expand on posts automatically. Default.
45+
# - always expand for all pages automatically
46+
# - hide expand only when click on the sidebar toggle icon.
47+
sidebar: post
48+
#sidebar: always
49+
#sidebar: hide
50+
51+
52+
# Automatically scroll page to section which is under <!-- more --> mark.
53+
scroll_to_more: true
54+
55+
56+
# Automatically add list number to toc.
57+
toc_list_number: true
58+
59+
# Automatically Excerpt
60+
auto_excerpt:
61+
enable: false
62+
length: 150
63+
64+
# Use Lato font
65+
# Note: this option is avialable only when the language is not `zh-Hans`
66+
use_font_lato: true
67+
68+
69+
## DO NOT EDIT THE FOLLOWING SETTINGS
70+
## UNLESS YOU KNOW WHAT YOU ARE DOING
71+
72+
# Use velocity to animate everything.
73+
use_motion: true
74+
75+
# Fancybox
76+
fancybox: true
77+
78+
# Static files
79+
vendors: vendors
80+
css: css
81+
js: js
82+
images: images
83+
84+
# Theme version
85+
version: 0.4.3.1

layout/_scripts/pages/post-details.swig

+1-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
}
3232

3333
function getTOCMaxHeight () {
34-
var $sidebarInner = $('.sidebar-inner');
3534
var height = $('.sidebar').height() -
3635
$tocSelector.position().top -
3736
$('.post-toc-indicator-bottom').height();
@@ -53,7 +52,7 @@
5352
)
5453
}
5554

56-
$(document).on('sidebar.didShow', function () {
55+
$(document).on('sidebar.motion.complete', function () {
5756
processTOC();
5857
});
5958

source/js/motion_global.js

+10-5
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ $(document).ready(function () {
3535

3636

3737
//当前选择的是目录列表时添加 class 'motion-element'
38-
sidebar.bind('click', function(e){
38+
sidebar.bind('click', function(e){
3939
if(!!$('.sidebar-nav-toc') && e.target == $('.sidebar-nav-toc')[0]){
4040
$('.post-toc-wrap').addClass('motion-element');
4141
}});
@@ -55,7 +55,7 @@ $(document).ready(function () {
5555
SIDEBAR_DISPLAY_DURATION
5656
);
5757
// sidebar 内容的效果应该在sidebarsidebarShowMotion内触发
58-
// sidebarContentMotion();
58+
// sidebarContentMotion();
5959
})
6060
.on('sidebar.isHiding', function () {});
6161

@@ -134,9 +134,14 @@ $(document).ready(function () {
134134
}
135135

136136
function sidebarContentMotion () {
137-
$('.sidebar .motion-element').velocity(
138-
'transition.slideRightIn',
139-
{stagger: 50, drag: true}
137+
$('.sidebar .motion-element')
138+
.velocity('transition.slideRightIn',{
139+
stagger: 50,
140+
drag: true,
141+
complete: function () {
142+
sidebar.trigger('sidebar.motion.complete');
143+
}
144+
}
140145
);
141146
}
142147

0 commit comments

Comments
 (0)