Last active
July 21, 2017 14:54
-
-
Save abrahamjuliot/7c28dd38036b827a35f5a62b98c105a9 to your computer and use it in GitHub Desktop.
page fade out transition
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
// 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