Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add an opt-out for transition cache

  • Loading branch information...
commit 73e423f748b2877ce173a6c8743411008f838270 1 parent f1872f4
@smidwap smidwap authored
Showing with 11 additions and 6 deletions.
  1. +11 −6 lib/assets/javascripts/turbolinks.js.coffee
View
17 lib/assets/javascripts/turbolinks.js.coffee
@@ -15,12 +15,16 @@ fetch = (url) ->
cacheCurrentPage()
reflectNewUrl url
- if cachedPage = pageCache[url]
+ if cachedPage = transitionCacheFor url
fetchHistory cachedPage
fetchReplacement url
else
fetchReplacement url, resetScrollPosition
+transitionCacheFor = (url) ->
+ cachedPage = pageCache[url]
+ cachedPage if cachedPage and !cachedPage.transitionCacheDisabled
+
fetchReplacement = (url, onLoadFunction = =>) ->
triggerEvent 'page:fetch', url: url
@@ -55,11 +59,12 @@ fetchHistory = (cachedPage) ->
cacheCurrentPage = ->
pageCache[currentState.url] =
- body: document.body,
- title: document.title,
- positionY: window.pageYOffset,
- positionX: window.pageXOffset,
- cachedAt: new Date().getTime()
+ body: document.body,
+ title: document.title,
+ positionY: window.pageYOffset,
+ positionX: window.pageXOffset,
+ cachedAt: new Date().getTime()
+ transitionCacheDisabled: document.querySelector('[data-no-transition-cache]')?
constrainPageCacheTo cacheSize
Please sign in to comment.
Something went wrong with that request. Please try again.