Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #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,
    Hiren

    #600505
    #600643

    Hi 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,
    Hiren

    #601810

    any 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!

    #603712

    Hey!

    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!
    Andy

    #604256

    Hi @Andy

    Above solution that you provided is already applied there. It is for active menu effect on click. We require something for On scroll. Something along the lines of Bootstrap Scrollspy

    Regards,
    Hiren

    #604525

    Hi,

    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, 8 months ago by Josue.
    #605014

    Our 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:

    #605145

    I wrote it wrong, check my message again.

    #605624

    Hi @Josue

    Still no luck. It is still not working. Please have a look:

    By the way, we are using child theme, does that matter?

    #605649

    Hey!

    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!
    Vinay

    #605652

    Hi @Vinnie (Vinay)

    You surely have permission to make the necessary changes. Login details included:

    #605702

    Hey!

    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!
    Vinay

    #605710

    Thanks 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.

    #605854

    Hi!

    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

Viewing 15 posts - 1 through 15 (of 15 total)
  • You must be logged in to reply to this topic.