Skip to content

Instantly share code, notes, and snippets.

@dillonhafer
Created June 6, 2014 15:18
Show Gist options
  • Save dillonhafer/8bbe1d52e0b76237f2cb to your computer and use it in GitHub Desktop.
Save dillonhafer/8bbe1d52e0b76237f2cb to your computer and use it in GitHub Desktop.
Darling Duffy
document.addEventListener('DOMContentLoaded', function(){
function fadeIn(el) {
el.style.opacity = 0;
var last = +new Date();
var tick = function() {
el.style.opacity = +el.style.opacity + (new Date() - last) / 400;
last = +new Date();
if (+el.style.opacity < 1) {
(window.requestAnimationFrame && requestAnimationFrame(tick)) || setTimeout(tick, 16)
}
};
tick();
}
function HideNextSiblings(el) {
if (el.nextElementSibling) {
el.nextElementSibling.style.display = 'none';
HideNextSiblings(el.nextElementSibling);
}
}
function ShowNextSiblings(el) {
if (el.nextElementSibling) {
el.nextElementSibling.style.display = '';
fadeIn(el.nextElementSibling);
ShowNextSiblings(el.nextElementSibling);
}
}
var read_more = document.querySelector('.read-more-bio');
if (read_more) {
HideNextSiblings(read_more.parentElement);
read_more.addEventListener('click', function(event) {
this.style.display = 'none';
ShowNextSiblings(this.parentElement);
event.preventDefault();
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment