From 2da59efd34cd1ca5ed00387d79523749790d22e0 Mon Sep 17 00:00:00 2001 From: "dreamran43@gmail.com" Date: Sun, 29 Apr 2018 16:55:28 +0800 Subject: [PATCH] Support Reload the page --- src/jquery.smoothState.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/jquery.smoothState.js b/src/jquery.smoothState.js index b14ba7e..24db6cc 100644 --- a/src/jquery.smoothState.js +++ b/src/jquery.smoothState.js @@ -505,7 +505,30 @@ window.location = url; } }, + /**Reload the page */ + reload = function () { + // Apply rate limiting. + if (!isRateLimited()) { + // Set the delay timeout until the next event is allowed. + setRateLimitRepeatTime(); + + // clear cache + cache = {}; + $container.data('smoothState').cache = cache; + + var request = utility.translate(window.location.href); + isTransitioning = true; + targetHash = window.location.hash; + + // Allows modifications to the request + request = options.alterRequest(request); + console.log(request); + options.onBefore(null, $container); + + load(request); + } + }, /** * Loads the contents of a url into our container * @param {string} url @@ -799,6 +822,7 @@ href: currentHref, cache: cache, clear: clear, + reload: reload, load: load, fetch: fetch, restartCSSAnimations: restartCSSAnimations