Skip to content

Instantly share code, notes, and snippets.

@0632347878
Created April 14, 2017 19:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 0632347878/d5f8712c718860f6d31477d3802af8d3 to your computer and use it in GitHub Desktop.
Save 0632347878/d5f8712c718860f6d31477d3802af8d3 to your computer and use it in GitHub Desktop.
var box = $('#box');
$('button').on('click', function () {
if (box.hasClass('hidden')) {
box.removeClass('hidden');
setTimeout(function () {
box.removeClass('visuallyhidden');
}, 20);
} else {
box.addClass('visuallyhidden');
box.one('transitionend', function(e) {
box.addClass('hidden');
});
}
});
.hidden {
display: none;
}
.visuallyhidden {
opacity: 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment