I want to toggle notification with jQuery UI-like blind effect: jQuery UI blind effect
To achieve it, I created CSS3 animations:
.blind-top-in{
-webkit-animation-duration: 2s;
-webkit-animation-name: blindTopIn;
animation-duration: 2s;
animation-name: blindTopIn;
}
.blind-top-out{
-webkit-animation-duration: 2s;
-webkit-animation-name: blindTopOut;
animation-duration: 2s;
animation-name: blindTopOut;
}
@-webkit-keyframes blindTopIn{
from{
max-height: 0px;
height: 0 !important;
}
to{
max-height: 75px;
height: auto !important;
}
}
@-webkit-keyframes blindTopOut{
from{
max-height: 75px;
height: auto !important;
}
to{
max-height: 0px;
height: 0 !important;
}
}
@keyframes blindTopIn{
from{
max-height: 0px;
height: 0 !important;
}
to{
max-height: 75px;
height: auto !important;
}
}
@keyframes blindTopOut{
from{
max-height: 75px;
height: auto !important;
}
to{
max-height: 0px;
height: 0 !important;
}
}
And idea is that it should blind from 0px width to auto/75px and backwards.
Unfortunately, this is not working - it looks like "half-height notification" appears and animate to normal height, then if I add blind-top-out
class it animate to half-height and then dissapears without animation. What am I doing wrong? I would be very happy if anybody decides to help me - thank you in advance.
Snippet - working not exactly like it should (I don't know why), but you see that animation animate only "half" of notification
.blind-top-in{
-webkit-animation-duration: 2s;
-webkit-animation-name: blindTopIn;
animation-duration: 2s;
animation-name: blindTopIn;
}
.blind-top-out{
-webkit-animation-duration: 2s;
-webkit-animation-name: blindTopOut;
animation-duration: 2s;
animation-name: blindTopOut;
}
@-webkit-keyframes blindTopIn{
from{
max-height: 0px;
height: 0 !important;
}
to{
max-height: 75px;
height: 75px !important;
}
}
@-webkit-keyframes blindTopOut{
from{
max-height: 75px;
height: 75px !important;
}
to{
max-height: 0px;
height: 0 !important;
}
}
@keyframes blindTopIn{
from{
max-height: 0px;
height: 0 !important;
}
to{
max-height: 75px;
height: 75px !important;
}
}
@keyframes blindTopOut{
from{
max-height: 75px;
height: 75px !important;
}
to{
max-height: 0px;
height: 0 !important;
}
}
<html>
<head>
<title>TODO supply a title</title>
<meta charset="windows-1250">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script type="text/javascript">
"use strict";
$(document).ready(function(){
$("#showBtn").click(function(){
$("#notification").addClass("blind-top-in").removeClass("blind-top-out")});
$("#hideBtn").click(function(){
$("#notification").addClass("blind-top-out").removeClass("blind-top-in");
});
});
</script>
</head>
<body class="container">
<div id="notification" class="alert alert-info">Notify user</div>
<button id="showBtn" class="btn btn-success btn-sm" style="margin-top: 50px;">Show</button>
<button id="hideBtn" class="btn btn-danger btn-sm" style="margin-top: 80px;">Hide</button>
</div>
</body>
</html>