Created
September 19, 2014 16:19
-
-
Save alobato/e17b202b6ab919fcf794 to your computer and use it in GitHub Desktop.
// source http://jsbin.com/zojuhi/1
This file contains 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
<!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> |
This file contains 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
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); | |
} |
This file contains 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
$(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