Skip to content
This repository has been archived by the owner on Apr 28, 2020. It is now read-only.

Commit

Permalink
Fix back button behavior in Chrome.
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Ferdinandi committed Jan 23, 2014
1 parent 16aee38 commit 7506bd6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ A simple script to animate scrolling to anchor links. Easing support contributed
Getting started with Smooth Scroll is really easy. [View the online tutorial](http://cferdinandi.github.com/smooth-scroll/) or dig through the `index.html` file.

## Changelog
* v2.19 (January 23, 2014)
* [Fix back button behavior in Chrome.](https://github.com/cferdinandi/smooth-scroll/issues/26#issuecomment-33172325)
* v2.18 (January 23, 2014)
* [Update URL before animation.](https://github.com/cferdinandi/smooth-scroll/pull/27)
* [Fix back button behavior in Firefox.](https://github.com/cferdinandi/smooth-scroll/issues/26)
Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ <h1 style="text-align: center; font-size: 3em;">Smooth Scroll</h1>

<p>
<strong>Linear</strong><br>
<a class="scroll" data-speed="2000" data-easing="linear" data-url="true" href="#bazinga">Linear (no other options)</a><br>
<a class="scroll" data-speed="2000" data-easing="linear" data-url="false" href="#bazinga">Linear (no other options)</a><br>
</p>

<p>
Expand Down
9 changes: 8 additions & 1 deletion smooth-scroll.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* =============================================================
Smooth Scroll 2.18
Smooth Scroll 2.19
Animate scrolling to anchor links, by Chris Ferdinandi.
http://gomakethings.com
Expand Down Expand Up @@ -133,6 +133,13 @@

});

// Return to the top of the page when back button is clicked and no hash is set
window.onpopstate = function (event) {
if ( event.state === null && window.location.hash === '' ) {
window.scrollTo( 0, 0 );
}
};

}

})();

0 comments on commit 7506bd6

Please sign in to comment.