I am working on creating a smooth overlay transition for when the sidebar menu opens and closes. When the overlay is clicked, I want the menu to close.
This is what I have so far:
$(document).ready(function() {
$('#menu-toggle').click(function(e) {
e.preventDefault();
$('#wrapper').toggleClass('toggled');
$('#overlay').toggle();
});
$('#overlay').click(function() {
$('#overlay').hide('200');
$('#wrapper').removeClass('toggled');
});
});
#overlay {
position: fixed;
z-index: 999;
top: 0;
right: 0;
bottom: 0;
left: 0;
display: none;
background-color: rgba(0,0,0,.5);
}
You can view the demo here.
Although my code is functioning properly, I am having difficulty achieving the desired animation effect. I would appreciate any help in improving the visual transition.
Specifically, I am aiming for an animation similar to android lollipop or material design effects.