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

Commit

Permalink
added reset scroll position per @moomerman issue #66
Browse files Browse the repository at this point in the history
  • Loading branch information
davydotcom committed Oct 3, 2012
1 parent a5e8156 commit e25c7b7
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/assets/javascripts/turbolinks.js.coffee
Expand Up @@ -23,6 +23,7 @@ fetchReplacement = (url) ->
unless assetsChanged extractAssetsFrom doc
changePage extractTitleAndBody(doc)...
reflectRedirectedUrl xhr
resetScrollPosition()
triggerEvent 'page:load'
xhr.onabort = -> console.log 'Aborted turbolink fetch!'
xhr.send()
Expand Down Expand Up @@ -89,6 +90,9 @@ rememberInitialPage = ->
recallScrollPosition = (page) ->
window.scrollTo page.positionX, page.positionY

resetScrollPosition = ->
window.scrollTo 0, 0

extractAssetsFrom = (doc) ->
headAssets = []
for script in document.head.getElementsByTagName 'script'
Expand Down

0 comments on commit e25c7b7

Please sign in to comment.