It is a wordpress site. I'm trying to animate header when scrolling. Here is the website. Here is the jQuery code:
jQuery(window).on("scroll", function() {
if (jQuery(window).scrollTop() > 45) {
jQuery(".fusion-header").addClass("active");
jQuery(".fusion-header").removeClass("top");
jQuery(".fusion-main-menu > ul > li > a").addClass("menu-sticky-color");
jQuery('.fusion-main-menu > ul > li > a').hover(
function() {
jQuery(this).addClass('hover2')
},
function() {
jQuery(this).removeClass('hover2')
}
) jQuery('.fusion-main-menu > ul > li > a').hover(
function() {
jQuery(this).removeClass('hover1')
}
) jQuery(".fusion-logo a").addClass("sticky-logo1");
jQuery(".fusion-logo a").removeClass("logo1");
} else {
jQuery(".fusion-main-menu > ul > li > a").removeClass("menu-sticky-color");
jQuery(".fusion-header").removeClass("active");
jQuery(".fusion-header").addClass("top");
jQuery(".fusion-logo a").addClass("logo1");
jQuery(".fusion-logo a").removeClass("sticky-logo1");
jQuery('.fusion-main-menu > ul > li > a').hover(
function() {
jQuery(this).addClass('hover1')
},
function() {
jQuery(this).removeClass('hover1')
}
) jQuery('.fusion-main-menu > ul > li > a').hover(
function() {
jQuery(this).removeClass('hover2')
}
)
}
});
Header transition is working from top to down (scrollTop() < 45), but when user scrolls to the top there is not reverse animation. I'm stuck on this for days and cannot figure out how to make transition from down to top when scrollTop() < 45. Thank you for any help!
hoverevents to elements on every scroll? Basically all this can be done with few lines of js for scroll position and some css. At the moment this is hardest way possible. - Rauli Rajande