From 88f4a38885b4a3f5fe7bf1af3aa4aeb3c433e684 Mon Sep 17 00:00:00 2001 From: ruanyf Date: Wed, 7 May 2014 22:30:15 +0800 Subject: [PATCH] edit js/ditto --- js/ditto.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/js/ditto.js b/js/ditto.js index a38ae7c..4a78dc7 100644 --- a/js/ditto.js +++ b/js/ditto.js @@ -248,6 +248,14 @@ function router() { })(); })(); + var perc = ditto.save_progress ? store.get('page-progress') || 0 : 0; + + if(location.hash !== '' || Boolean(perc)){ + $('html, body').animate({ + scrollTop: Boolean(perc)?($('body').height()-$(window).height())*perc:$('#content').offset().top + }, 200); + } + if (location.hash === '' || location.hash === menu[0]) { $('#pageup').css('display', 'none'); } else { @@ -266,7 +274,6 @@ function router() { var wh = $w.height(); var h = $('body').height(); var sHeight = h - wh; - var perc = ditto.save_progress ? store.get('page-progress') || 0 : 0; $w.off('scroll').on('scroll', function() { var perc = Math.max(0, Math.min(1, $w.scrollTop() / sHeight)); @@ -278,10 +285,6 @@ function router() { ditto.save_progress && store.set('page-progress', perc); } - updateProgress(perc); - $('html, body').animate({ - scrollTop: sHeight * perc - }, 200); }()); }).fail(function() {