Skip to content

Commit 6568da7

Browse files
koenpuntkswedberg
authored andcommitted
Request window location on every click.
* Since history.pushState exists, the location can change without a page reload. * So, need to check link href against window.location href every time. * Closes kswedberg#89
1 parent dfe6c9e commit 6568da7

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/jquery.smooth-scroll.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,7 @@
114114
});
115115
}
116116

117-
var opts = $.extend({}, $.fn.smoothScroll.defaults, options),
118-
locationPath = $.smoothScroll.filterPath(location.pathname);
117+
var opts = $.extend({}, $.fn.smoothScroll.defaults, options);
119118

120119
var clickHandler = function(event) {
121120
var link = this,
@@ -126,8 +125,10 @@
126125
elCounter = 0, ewlCounter = 0,
127126
include = true,
128127
clickOpts = {},
128+
locationPath = $.smoothScroll.filterPath(location.pathname),
129+
linkPath = $.smoothScroll.filterPath(link.pathname),
129130
hostMatch = ((location.hostname === link.hostname) || !link.hostname),
130-
pathMatch = thisOpts.scrollTarget || ( $.smoothScroll.filterPath(link.pathname) === locationPath ),
131+
pathMatch = thisOpts.scrollTarget || ( linkPath === locationPath ),
131132
thisHash = escapeSelector(link.hash);
132133

133134
if ( !thisOpts.scrollTarget && (!hostMatch || !pathMatch || !thisHash) ) {

0 commit comments

Comments
 (0)