Skip to content

Commit 951dcc2

Browse files
author
Chris Ferdinandi
committed
Accomodate query strings when updating URL
1 parent 4d55d99 commit 951dcc2

File tree

7 files changed

+13
-16
lines changed

7 files changed

+13
-16
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ If the `<body>` element has been assigned a height of `100%`, Smooth Scroll is u
233233
* AMD support and numerous code improvements by [Todd Motto](https://github.com/toddmotto).
234234
* Push State bug fix by [Yanick Witschi](https://github.com/Toflar).
235235
* CommonJS module support by [Riku Rouvila](https://github.com/rikukissa).
236+
* Query string fix when updating URL by [Qu Yatong](https://github.com/quyatong).
236237
* Unit tests by [Thibaud Colas](https://github.com/ThibWeb).
237238

238239

@@ -252,6 +253,8 @@ Smooth Scroll is licensed under the [MIT License](http://gomakethings.com/mit/).
252253

253254
Smooth Scroll uses [semantic versioning](http://semver.org/).
254255

256+
* v5.2.2 - December 13, 2014
257+
* Updating URL now accounts for query strings.
255258
* v5.2.1 - December 13, 2014
256259
* Added unit tests.
257260
* v5.2.0 - November 21, 2014

dist/js/smooth-scroll.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* smooth-scroll v5.2.1
2+
* smooth-scroll v5.2.2
33
* Animate scrolling to anchor links, by Chris Ferdinandi.
44
* http://github.com/cferdinandi/smooth-scroll
55
*
@@ -255,9 +255,7 @@
255255
*/
256256
var updateUrl = function ( anchor, url ) {
257257
if ( history.pushState && (url || url === 'true') ) {
258-
history.pushState( {
259-
pos: anchor.id
260-
}, '', window.location.pathname + anchor );
258+
history.pushState( null, null, [root.location.protocol, '//', root.location.host, root.location.pathname, root.location.search, anchor].join('') );
261259
}
262260
};
263261

dist/js/smooth-scroll.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/dist/js/smooth-scroll.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* smooth-scroll v5.2.1
2+
* smooth-scroll v5.2.2
33
* Animate scrolling to anchor links, by Chris Ferdinandi.
44
* http://github.com/cferdinandi/smooth-scroll
55
*
@@ -255,9 +255,7 @@
255255
*/
256256
var updateUrl = function ( anchor, url ) {
257257
if ( history.pushState && (url || url === 'true') ) {
258-
history.pushState( {
259-
pos: anchor.id
260-
}, '', window.location.pathname + anchor );
258+
history.pushState( null, null, [root.location.protocol, '//', root.location.host, root.location.pathname, root.location.search, anchor].join('') );
261259
}
262260
};
263261

docs/dist/js/smooth-scroll.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "smooth-scroll",
3-
"version": "5.2.1",
3+
"version": "5.2.2",
44
"description": "Animate scrolling to anchor links",
55
"main": "./dist/js/smooth-scroll.js",
66
"author": {

src/js/smooth-scroll.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,7 @@
246246
*/
247247
var updateUrl = function ( anchor, url ) {
248248
if ( history.pushState && (url || url === 'true') ) {
249-
history.pushState( {
250-
pos: anchor.id
251-
}, '', window.location.pathname + anchor );
249+
history.pushState( null, null, [root.location.protocol, '//', root.location.host, root.location.pathname, root.location.search, anchor].join('') );
252250
}
253251
};
254252

0 commit comments

Comments
 (0)