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

Commit

Permalink
Don't scroll to top on partial replacement
Browse files Browse the repository at this point in the history
  • Loading branch information
Thibaut committed May 10, 2015
1 parent 7a8e631 commit 6cadc8d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/assets/javascripts/turbolinks.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fetch = (url, options = {}) ->
options.showProgressBar = false
fetchReplacement url, options
else
options.onLoadFunction = resetScrollPosition
options.onLoadFunction = resetScrollPosition unless options.change
fetchReplacement url, options

transitionCacheFor = (url) ->
Expand Down
8 changes: 8 additions & 0 deletions test/javascript/turbolinks_visit_test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -258,3 +258,11 @@ suite 'Turbolinks.visit()', ->
@window.scrollTo(42, 42)
@Turbolinks.pagesCached(0)
@Turbolinks.visit('iframe2.html')

test "doesn't scroll to top with :change", (done) ->
@window.scrollTo(42, 42)
@document.addEventListener 'page:load', =>
assert.equal @window.pageXOffset, 42
assert.equal @window.pageYOffset, 42
done()
@Turbolinks.visit('iframe2.html', change: ['change'])

0 comments on commit 6cadc8d

Please sign in to comment.