diff --git a/js/ditto.js b/js/ditto.js index 031c301..4295e1e 100644 --- a/js/ditto.js +++ b/js/ditto.js @@ -192,7 +192,7 @@ function show_loading() { return loading; } -function router() { +function router() { var path = location.hash.replace("#", "./"); @@ -212,6 +212,10 @@ function router() { path = path + ".md"; } + // 取消scroll事件的监听函数 + // 防止改变下面的变量perc的值 + $(window).off('scroll'); + // otherwise get the markdown and render it var loading = show_loading(); $.get(path, function(data) { @@ -283,7 +287,7 @@ function router() { var h = $('body').height(); var sHeight = h - wh; - $w.off('scroll').on('scroll', function() { + $w.on('scroll', function() { var perc = Math.max(0, Math.min(1, $w.scrollTop() / sHeight)); updateProgress(perc); });