Skip to content

Instantly share code, notes, and snippets.

@abrahamjuliot
Last active July 21, 2017 14:54
Show Gist options
  • Save abrahamjuliot/7c28dd38036b827a35f5a62b98c105a9 to your computer and use it in GitHub Desktop.
Save abrahamjuliot/7c28dd38036b827a35f5a62b98c105a9 to your computer and use it in GitHub Desktop.
page fade out transition
// Page Transition
(function () {
"use strict";
var
doc = document,
$content = doc.querySelector('#content'),
$main = doc.querySelector('#main'),
$footer = doc.querySelector('.prefooter'),
$links = doc.querySelectorAll('#content a[href^="/"]'),
len = $links.length,
ran = false,
pageTransition = function(e) {
if (
e.ctrlKey || // new tab
e.shiftKey || // new window
e.metaKey || // apple
(e.button && e.button == 1) // middle click
) {return;}
if (!ran) {
e.preventDefault();
}
setTimeout(function() {
$main.classList.add('page-fade-down');
$footer.classList.add('page-fade-down');
e.target.click();
console.log(e.target);
ran = true;
}, 200);
// set interval to check true?
};
// should instead use one listener and if e.target == link
for (var i = 0; i < len; i++) {
$links[i].addEventListener('click', pageTransition);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment