From ba96993007fccbd8408553378083c7c437bdd2a4 Mon Sep 17 00:00:00 2001 From: butanosuke Date: Sat, 11 Jul 2015 13:03:20 +0900 Subject: [PATCH] Make the page number go between 1 and the last page number. --- jquery.onepage-scroll.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/jquery.onepage-scroll.js b/jquery.onepage-scroll.js index 71c75ba..cf263df 100644 --- a/jquery.onepage-scroll.js +++ b/jquery.onepage-scroll.js @@ -150,7 +150,11 @@ $("body").addClass("viewing-page-"+next.data("index")) if (history.replaceState && settings.updateURL == true) { - var href = window.location.href.substr(0,window.location.href.indexOf('#')) + "#" + (index + 1); + if(index == total){ + var href = window.location.href.substr(0,window.location.href.indexOf('#')) + "#" + 1; + } else{ + var href = window.location.href.substr(0,window.location.href.indexOf('#')) + "#" + (index + 1); + } history.pushState( {}, document.title, href ); } el.transformPage(settings, pos, next.data("index")); @@ -184,7 +188,11 @@ $("body").addClass("viewing-page-"+next.data("index")) if (history.replaceState && settings.updateURL == true) { - var href = window.location.href.substr(0,window.location.href.indexOf('#')) + "#" + (index - 1); + if(index == 1){ + var href = window.location.href.substr(0,window.location.href.indexOf('#')) + "#" + total; + } else{ + var href = window.location.href.substr(0,window.location.href.indexOf('#')) + "#" + (index - 1); + } history.pushState( {}, document.title, href ); } el.transformPage(settings, pos, next.data("index"));