Skip to content

Instantly share code, notes, and snippets.

@alobato
Created September 19, 2014 16:19
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 alobato/e17b202b6ab919fcf794 to your computer and use it in GitHub Desktop.
Save alobato/e17b202b6ab919fcf794 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
<style id="jsbin-css">
div {
display: none;
width: 100px; height: 100px;
background: blue;
}
.will-show {
display: block;
opacity: 0;
//transform: scale(0);
}
.show {
opacity: 1;
transition: opacity 2s ease;
//transform: scale(1);
//transition-duration: 2s;
}
.hide {
opacity: 0;
//transform: scale(0);
}
</style>
</head>
<body>
<div></div>
<button id="btn-show">show</button>
<button id="btn-hide">hide</button>
<script id="jsbin-javascript">
$(function() {
$('#btn-show').click(function() {
$('div').addClass('will-show');
return setTimeout((function() {
return $('div').addClass('show');
}), 20);
});
return $('#btn-hide').click(function() {
$('div').addClass('hide');
return setTimeout((function() {
return $('div').removeClass('show').removeClass('will-show').removeClass('hide');
}), 2000);
});
});
</script>
<script id="jsbin-source-html" type="text/html"><!DOCTYPE html>
<html>
<head>
<script src="//code.jquery.com/jquery-1.11.1.min.js"><\/script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<div></div>
<button id="btn-show">show</button>
<button id="btn-hide">hide</button>
</body>
</html></script>
<script id="jsbin-source-css" type="text/css">div {
display: none;
width: 100px; height: 100px;
background: blue;
}
.will-show {
display: block;
opacity: 0;
//transform: scale(0);
}
.show {
opacity: 1;
transition: opacity 2s ease;
//transform: scale(1);
//transition-duration: 2s;
}
.hide {
opacity: 0;
//transform: scale(0);
}</script>
<script id="jsbin-source-javascript" type="text/javascript">$ ->
$('#btn-show').click ->
$('div').addClass('will-show')
setTimeout (-> $('div').addClass('show')), 20
$('#btn-hide').click ->
$('div').addClass('hide')
setTimeout (-> $('div').removeClass('show').removeClass('will-show').removeClass('hide')), 2000</script></body>
</html>
div {
display: none;
width: 100px; height: 100px;
background: blue;
}
.will-show {
display: block;
opacity: 0;
//transform: scale(0);
}
.show {
opacity: 1;
transition: opacity 2s ease;
//transform: scale(1);
//transition-duration: 2s;
}
.hide {
opacity: 0;
//transform: scale(0);
}
$(function() {
$('#btn-show').click(function() {
$('div').addClass('will-show');
return setTimeout((function() {
return $('div').addClass('show');
}), 20);
});
return $('#btn-hide').click(function() {
$('div').addClass('hide');
return setTimeout((function() {
return $('div').removeClass('show').removeClass('will-show').removeClass('hide');
}), 2000);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment