Joined March 2012
·

Adam Ahmed

Javascript Developer at Atlassian
·
Sydney, Australia
·
·
·

Posted to Fade out page when clicking links over 1 year ago

Yeah I'm with @gma. I'm pretty sure what you really should be doing if you want to make page transitions pretty is not actually do page transitions at all. The History API is for exactly this purpose.

Something like (but not exactly - this is untested):

a.onclick = function(e) {
    e.preventDefault();
    fadeOut().then(function() {
        history.pushState(null, null, a.href);
        load(a.href).then(fadeIn);
    });
};
window.onpopstate = function() {
    fadeOut.then(loadContent).then(fadeIn);
}
Achievements
59 Karma
0 Total ProTip Views