-
AuthorPosts
-
March 18, 2016 at 10:46 am #600190
Hi guys,
how do we highlight anchor points when someone scrolls the page. Just like it does in ‘one page’ main sticky menu?
As requested by @vinnie herewith i have included all the details.
Regards,
HirenMarch 18, 2016 at 7:21 pm #600505Hi hirens!
Please refer to this post – http://kriesi.at/documentation/enfold/add-anchors-to-your-page-for-single-page-navigation/
Cheers!
YigitMarch 19, 2016 at 9:45 am #600643Hi Yigit,
As already mentioned in my previous post, I have no issue setting up anchor points and enabling clicks to anchor points with menu. That is all working fine.
My question is around – highlighting active anchor points in sidebar menu with page scroll. Please have a look at this page: https://hikepos.com.au/pos-hardware – when I click on item, it scrolls and highlights but I want the menu to be highlighted even if I use mouse scroll to go to the section. Just like it works with your one page example.
Could you please advise.
Kind regards,
HirenMarch 22, 2016 at 11:13 am #601810any update guys, sorry to try and bump but I am waiting on answer since March 3rd, we’re in now third week without any good response from you guys. Before you ask – yes this ticket was created on 18th but the question was originally posted on another thread on 3rd, then you guys asked me to create a new ticket…basically a big fan on Enfold, it is just this time i thought a need of mentioning the delay. Normally you guys rock!
March 25, 2016 at 9:08 pm #603712Hey!
try this code in your functions.php:
add_action('wp_footer', 'wp_footer_mod'); function wp_footer_mod(){ ?> <script> (function($){ $('#top .widget_nav_menu li').on('click', function(event) { $('#top .widget_nav_menu li').each(function() { $(this).removeClass('current-menu-item'); }); $(this).addClass('current-menu-item'); }); })(jQuery); </script> <?php }
and then use this inside your Quick CSS field:
.current-menu-item a { color: #35bdb2; }
Cheers!
AndyMarch 29, 2016 at 6:08 am #604256March 29, 2016 at 1:48 pm #604525Hi,
Open js/avia.js and look for line:
$('body').avia_scrollspy({target:'.main_menu .menu li > a'});
Replace it by this:
$('body').avia_scrollspy({target:'#top .widget_nav_menu li > a'});
Regards,
Josue- This reply was modified 8 years, 7 months ago by Josue.
March 30, 2016 at 8:22 am #605014Our JS/avia.js already have that line as below:
if(container == 'body') { $('body').avia_scrollspy({target:'.main_menu .menu li > a'}); } else { $('body').avia_scrollspy('refresh'); }
Still no luck. It does not seem to be working. Again i have included the url for below:
March 30, 2016 at 1:50 pm #605145I wrote it wrong, check my message again.
March 31, 2016 at 5:08 am #605624March 31, 2016 at 6:46 am #605649Hey!
As i understand you need the left menu to highlight when the page is scrolled… We would like to take a closer look at the issue please create a temporary user with ‘administrator’ role and share in private content with permission to deactivate all plugins and add custom code if necessary to help you resolve this issue.
Cheers!
VinayMarch 31, 2016 at 6:54 am #605652Hi @Vinnie (Vinay)
You surely have permission to make the necessary changes. Login details included:
March 31, 2016 at 8:36 am #605702Hey!
Please review the page now the menu highlights as you scroll the page you need to add class name “avia-section” to add the #ID check the code block for edited code.
Then we added the below code in functions.php
//One page nav highlight function activateMenuItem(){ ?> <script> jQuery(document).scroll(function() { var sections = jQuery('.avia-section'), menu = jQuery('#menu-hardware'), nav_height = menu.outerHeight(); jQuery(window).on('scroll', function() { var cur_pos = jQuery(this).scrollTop(); sections.each(function() { var top = jQuery(this).offset().top - 300, bottom = top + jQuery(this).outerHeight(); if (cur_pos >= top && cur_pos <= bottom) { menu.find('a').removeClass('active-menu-item'); menu.find('a[href="#' + jQuery(this).attr('id') + '"]').addClass('active-menu-item'); } }); }); }); </script> <?php } add_action('wp_head', 'activateMenuItem');
and the below css in Enfold > general Styling > Quick CSS (at the bottom)
Edit the below CSS to change the highlight style/* active menu item*/ .current_page_item .avia-menu-text, .active-menu-item { background:gold!important; }
Cheers!
VinayMarch 31, 2016 at 8:52 am #605710Thanks Vinay – @vinnie
Great, i replaced the background with select colour and it is looking great.
However, just one minor glitch. When you scroll quickly and if you do not pass within that 300px offset that you have set, the active menu code is not working properly. For example, if i am not 6th menu and quickly scroll back to 2nd menu – the page still shows the 6th as selected in some occasions.
March 31, 2016 at 1:10 pm #605854Hi!
The execution takes place when the page is scrolled not sure if it is a browser issue that it is not triggering the scroll when you scroll fast. It is very much possible that the browsers have a limitation to trigger the number of pixels…
You can change the top 300 offset height to 200 or 100 it should still work just fine just changes the ID when the section is scrolled x pixels offset from the top.
Regards,
Vinay -
AuthorPosts
- You must be logged in to reply to this topic.