Skip to content

Instantly share code, notes, and snippets.

@jamonholmgren
Created March 13, 2013 18:21
Show Gist options
  • Save jamonholmgren/5154738 to your computer and use it in GitHub Desktop.
Save jamonholmgren/5154738 to your computer and use it in GitHub Desktop.
$(document).on "page:change", ->
window.prevPageYOffset = window.pageYOffset
window.prevPageXOffset = window.pageXOffset
$(document).on "page:load", ->
if $(".fix-scroll").length > 0
$('.fix-scroll').hide().show() # force re-render -- having an issue with that on Chrome/OSX
window.scrollTo window.prevPageXOffset, window.prevPageYOffset
@pokonski
Copy link

Thank your publishing the solution, really neat :)

@jnstq
Copy link

jnstq commented May 22, 2013

Should fix-scroll be added to the body-tag?

@nateberkopec
Copy link

This doesn't work on Turbolinks master anymore - the scroll position change happens before the page:change event fires.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment