Skip to content

Commit f389f2a

Browse files
committed
edit js/ditto
1 parent b96360e commit f389f2a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

js/ditto.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ function show_loading() {
192192
return loading;
193193
}
194194

195-
function router() {
195+
function router() {
196196

197197
var path = location.hash.replace("#", "./");
198198

@@ -212,6 +212,10 @@ function router() {
212212
path = path + ".md";
213213
}
214214

215+
// 取消scroll事件的监听函数
216+
// 防止改变下面的变量perc的值
217+
$(window).off('scroll');
218+
215219
// otherwise get the markdown and render it
216220
var loading = show_loading();
217221
$.get(path, function(data) {
@@ -283,7 +287,7 @@ function router() {
283287
var h = $('body').height();
284288
var sHeight = h - wh;
285289

286-
$w.off('scroll').on('scroll', function() {
290+
$w.on('scroll', function() {
287291
var perc = Math.max(0, Math.min(1, $w.scrollTop() / sHeight));
288292
updateProgress(perc);
289293
});

0 commit comments

Comments
 (0)