PDA

View Full Version : Change menu from hover into on-click



chechu
01-27-2015, 03:12 PM
Hey all,

Currently I have a fixed header menu that shows itself on hover (see here (http://www.lichaamengeest.be)). I'd like to change that into on-click.
Below is the js code. What do I need to change, please?
Thanks.


$(document).ready(function()
{

var header_h = $("#header-wrapper").height() + 0;
var menu_h = $("#menu").height();
var speed = 500;
var logo2_url = "http://www.lichaamengeest.be/img/transparant.png";

var scroll_critical = parseInt(header_h - menu_h);
var window_y = 0;
var menu_left_margin = 100;
menu_left_margin = parseInt($(".header").css("width")) - parseInt($("ul.menu").width());

window_y = $(window).scrollTop();
var $logo2_link = $("<a/>", {"href": "index.php"})
var $logo2 = $("<img />", {"src" : logo2_url, "class" : "logo2"}).appendTo($logo2_link);


if ( (window_y > scroll_critical) && !(is_touch_device()) ) header_transform();

function header_transform(){
window_y = $(window).scrollTop();

if (window_y > scroll_critical) {
if (!($("#header-wrapper").hasClass("fixed"))){
$("#header-wrapper").hide();
$("#wrapper").css("margin-top", header_h + "px");
$("#header-wrapper").addClass("fixed");
$("#header-wrapper").fadeIn(500);
$logo2_link.fadeIn().appendTo(".header");
}


} else {
if (($("#header-wrapper").hasClass("fixed"))){
$("#header-wrapper").fadeOut(500, function(){
$("#header-wrapper").removeClass("fixed");
$("#wrapper").css("margin-top", "");
$("#header-wrapper").fadeIn(300)
});

$logo2_link.fadeOut().remove();
}

}
}



$(window).scroll(function(){
if (!(is_touch_device())) header_transform();

})


});

chechu
02-04-2015, 11:25 AM
Anyone, please?

molendijk
02-04-2015, 02:00 PM
In your js/custom.js, there's a lot of hover. What happens if you replace that with click?

chechu
02-04-2015, 02:06 PM
Just changed hover into click, but nothing happens.
I replaced it by this, but still no result: https://gist.github.com/JamieS/917446
These don't seem to work: http://stackoverflow.com/questions/7312414/superfish-jquery-menu-open-on-click-rather-than-hover

chechu
02-20-2015, 11:58 AM
Anyone, please?