1
0
mirror of https://github.com/ruanyf/es6tutorial.git synced 2025-05-24 18:32:22 +00:00

edit js/ditto

This commit is contained in:
ruanyf 2014-05-07 23:35:05 +08:00
parent b96360ec89
commit f389f2af69

View File

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