Skip to content

Instantly share code, notes, and snippets.

@OutThisLife
Created December 22, 2016 22:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OutThisLife/09887061fae90ec66e3178593b0d5c35 to your computer and use it in GitHub Desktop.
Save OutThisLife/09887061fae90ec66e3178593b0d5c35 to your computer and use it in GitHub Desktop.
Fix for iOS back/forward button when using CSS animations to load in and out the content.
const $container = document.getElementById('container')
window.onpageshow = (e) => e.persisted ? window.location.reload() : null
export default function(href) {
document.body.classList.remove('load-in')
document.body.classList.add('load-out')
;['animationend', 'webkitAnimationEnd'].map(evt => {
$container.addEventListener(evt, (e) => {
location.href = href
$container.removeEventListener(e.type, arguments.callee)
})
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment