Created
December 22, 2016 22:49
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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