Skip to content

Commit f142f27

Browse files
committed
fix toc scrolltop animation
1 parent 2a870ae commit f142f27

File tree

3 files changed

+28
-29
lines changed

3 files changed

+28
-29
lines changed

_layouts/blog.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,3 @@ <h4>看看这个?</h4>
4646
<script src="/assets/js/blog.js"></script>
4747
{% include latex.html %}
4848
</article>
49-

assets/js/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ document.addEventListener('DOMContentLoaded', function () {
3737
icon: 'fa-code-fork',
3838
url: 'https://github.com/harttle/harttle.github.io',
3939
target: '_blank'
40+
}, {
41+
plugin: 'twitter',
42+
url: 'https://twitter.com/harttleharttle',
43+
target: '_blank'
4044
}, {
4145
plugin: 'rss',
4246
url: 'http://harttle.land/feed.xml',
@@ -48,10 +52,6 @@ document.addEventListener('DOMContentLoaded', function () {
4852
}, {
4953
plugin: 'qrcode',
5054
title: '扫一扫!'
51-
}, {
52-
plugin: 'linkedin',
53-
url: 'https://linkedin.com/in/harttle',
54-
target: '_blank'
5555
}]
5656
socialShare($('.follow').get(0), links, {size: 'sm'})
5757
})

assets/js/scrolltop.js

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
$(function () {
2-
$('a.animate').click(scrollTop)
2+
$('body').on('click', 'a.animate', scrollTop)
33
initScrollTopButton()
4-
})
54

6-
function scrollTop () {
7-
$('html, body').stop().animate({
8-
scrollTop: $($(this).attr('href')).offset().top
9-
}, 500, 'swing')
10-
return false
11-
}
5+
function scrollTop () {
6+
$('html, body').stop().animate({
7+
scrollTop: $($(this).attr('href')).offset().top
8+
}, 500, 'swing')
9+
return false
10+
}
1211

13-
function initScrollTopButton () {
14-
var $window = $(window)
15-
var topDistance = 300
16-
var shown = false
17-
var $btn = $('#site-scroll-top')
18-
$window.scroll(function () {
19-
if ($window.scrollTop() > topDistance) {
20-
if (!shown) {
21-
shown = true
22-
$btn.addClass('show')
12+
function initScrollTopButton () {
13+
var $window = $(window)
14+
var topDistance = 300
15+
var shown = false
16+
var $btn = $('#site-scroll-top')
17+
$window.scroll(function () {
18+
if ($window.scrollTop() > topDistance) {
19+
if (!shown) {
20+
shown = true
21+
$btn.addClass('show')
22+
}
23+
} else if (shown) {
24+
$btn.removeClass('show')
25+
shown = false
2326
}
24-
} else if (shown) {
25-
$btn.removeClass('show')
26-
shown = false
27-
}
28-
})
29-
}
27+
})
28+
}
29+
})

0 commit comments

Comments
 (0)