What is happening
Using .hide()
and .fadeIn(200)
is creating this jumpy effect, which I don't want.
What I want to happen
- When the user hovers over the menu icon,
- the menu icon to disappear
- the text "Problems" to fadeIn its place
- When the user moves their mouse away,
- the text "Problem" to disappear
- the menu icon to fadeIn its place
So I looked at this post which talked about using visibility to show/hide elements. I feel like using visibility might be the key. The only thing is I want the menu icon and "Problems" to replace each other, and w/out the display
set to none
, they are stacked on top of each other like so:
So if I were to use visibility, there would be gaps created by the hidden element.
My Code
HTML
<div id="Menu-Header" class="header">
<button id="Menu-Button" type="button" class="btn btn-default btn-lg button-menu" aria-label="Menu">
<span class="glyphicon glyphicon-menu-hamburger" aria-hidden="true"></span>
<h1>Problems</h1>
</button>
</div>
CSS
#Menu-Header h1 {
font-weight: 300;
text-align: center;
text-transform: uppercase;
display: none;
}
jQuery
$('#Menu-Button').on('mouseenter cick', function(){
$(this).children('.glyphicon-menu-hamburger').hide();
$(this).children('h1').fadeIn(200);
});
$('#Menu-Button').on('mouseleave', function(){
$(this).children('h1').hide();
$(this).children('.glyphicon-menu-hamburger').fadeIn(200);
});