From 31e3158d5295cb9ac175474f60ad2a7db532c25d Mon Sep 17 00:00:00 2001 From: patvice Date: Tue, 26 Jul 2016 09:59:24 -0400 Subject: [PATCH] added option to keep scroll position when using Page.refresh --- lib/assets/javascripts/turbograft/turbolinks.coffee | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/assets/javascripts/turbograft/turbolinks.coffee b/lib/assets/javascripts/turbograft/turbolinks.coffee index 5dec1d32..aec9ba04 100644 --- a/lib/assets/javascripts/turbograft/turbolinks.coffee +++ b/lib/assets/javascripts/turbograft/turbolinks.coffee @@ -75,7 +75,8 @@ class window.Turbolinks options.partialReplace ?= false options.onlyKeys ?= [] options.onLoadFunction = -> - resetScrollPosition() unless options.onlyKeys.length + if !options.onlyKeys.length || options.keepScrollPosition + resetScrollPosition() options.callback?() fetchReplacement url, options