- Posts: 2
- Thank you received: 0
Add Active/Current class to Navigation?
-
Naumangla
Inactive member - Topic Author
- New Member
Less
More
11 years 10 months ago #26605
by Naumangla
Add Active/Current class to Navigation? was created 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
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.
-
ivan.milic
Support Staff - Moderator
Less
More
- Posts: 14116
- Thank you received: 1639
11 years 10 months ago - 11 years 10 months ago #26613
by ivan.milic
Replied by ivan.milic on topic Add Active/Current class to Navigation?
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
/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: 11 years 10 months ago by ivan.milic.
The following user(s) said Thank You: Naumangla
Please Log in to join the conversation.
-
Naumangla
Inactive member - Topic Author
- New Member
Less
More
- Posts: 2
- Thank you received: 0
11 years 10 months ago #26630
by Naumangla
Replied by Naumangla on topic Add Active/Current class to Navigation?
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.
-
ivan.milic
Support Staff - Moderator
Less
More
- Posts: 14116
- Thank you received: 1639
11 years 10 months ago #26638
by ivan.milic
Replied by ivan.milic on topic Add Active/Current class to Navigation?
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.144 seconds