From 8fe276d0b16e834751408ded7611a3e9f7f87b07 Mon Sep 17 00:00:00 2001 From: Koen Punt Date: Wed, 23 Dec 2015 14:56:17 +0100 Subject: [PATCH] request window location on every click since history.pushState exists, the location can change without a page reload. so when using pushState the locationPath was never reset, which resulted in incorrect link exclusion --- src/jquery.smooth-scroll.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/jquery.smooth-scroll.js b/src/jquery.smooth-scroll.js index 50f8127..01d0126 100644 --- a/src/jquery.smooth-scroll.js +++ b/src/jquery.smooth-scroll.js @@ -114,8 +114,7 @@ }); } - var opts = $.extend({}, $.fn.smoothScroll.defaults, options), - locationPath = $.smoothScroll.filterPath(location.pathname); + var opts = $.extend({}, $.fn.smoothScroll.defaults, options); var clickHandler = function(event) { var link = this, @@ -126,8 +125,10 @@ elCounter = 0, ewlCounter = 0, include = true, clickOpts = {}, + locationPath = $.smoothScroll.filterPath(location.pathname), + linkPath = $.smoothScroll.filterPath(link.pathname), hostMatch = ((location.hostname === link.hostname) || !link.hostname), - pathMatch = thisOpts.scrollTarget || ( $.smoothScroll.filterPath(link.pathname) === locationPath ), + pathMatch = thisOpts.scrollTarget || ( linkPath === locationPath ), thisHash = escapeSelector(link.hash); if ( !thisOpts.scrollTarget && (!hostMatch || !pathMatch || !thisHash) ) {