Add Active/Current class to Navigation?

More
12 years 9 months ago #26605 by Naumangla
Hi, I'm wondering if there's a way to add a class to the active/current menu item -- one that also activates when the proper <a> is scrolled past.

See this page for an example of what I'm looking for: webdesigntutsplus.s3.amazonaws.com/tuts/...ints/demo/index.html

Thanks

Please Log in to join the conversation.

More
12 years 9 months ago - 12 years 9 months ago #26613 by ivan.milic
Open:

/templates/hot_one_page/js/hot_onepage.js

replace:

jQuery(".scroll, .mp_topmenu a").click(function(event){
event.preventDefault();
jQuery('html,body').animate({scrollTop:jQuery(this.hash).offset().top}, 500);
});

with:

jQuery(".scroll, .mp_topmenu a:not(.external)").click(function(event){

jQuery(".yourclass").removeClass("yourclass");
jQuery(this).closest("LI").addClass("yourclass");

event.preventDefault();
try{
jQuery('html,body').animate({scrollTop:jQuery(this.hash).offset().top}, 500);
}catch(e){
jQuery('html,body').animate({scrollTop:0}, 500);
}
});


replace yourclass with some other word you like .

I recommend: active
because that is joomla default
Last edit: 12 years 9 months ago by ivan.milic.
The following user(s) said Thank You: Naumangla

Please Log in to join the conversation.

More
12 years 9 months ago #26630 by Naumangla
Thank you, that worked for the click action, but can the class also be added when that particular area is manually scrolled to?

Please Log in to join the conversation.

More
12 years 9 months ago #26638 by ivan.milic
I understand what you want. It can be made but it can be treated only us custom job so you would have to pay for it.

Please Log in to join the conversation.

Time to create page: 0.346 seconds
Powered by Kunena Forum