JQuery triggering fadeIn and fadeOut on menu
Demo - https://jsfiddle.net/jhhpLapv/1/
// Main Script For Ciel Viole
$(document).ready(function() {
$('.client-link').click(function() {
$('.navbar').slideToggle("fast");
});
});
When triggering the hamburger menu, I want the menu links to fadein and subsequently fadeout when the menu is closed. I am very new to this and about as far as I have gotten. How can I listen to the event to trigger the fade in the first time the menu is clicked, and fade out the second time it is clicked?
Answers 1
Always try css based animations. They are very smooth and easy to implement.
Here is how. Instead of calling
fadeIn()
andfadeOut()
just add a class to the targeted element. Then in css you can usetransition: all 0.3s ease-in;
(or any other preferable values) to create a transition. Below is just an example using your code. You can make it way, way better than this.