Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #1245232

    hello, unfortunately the full width menu in combination with the one-page menu highlight stoped working. it reacts very flaky and slows down the page scroll behavior a lot. it seems to be related to the jquery script in the function.php.

    i am running the latest wp 5.5.1 and the latest enfold version 4.7.6.3

    any help is very much appreciated!

    best
    chris

    • This topic was modified 4 years, 2 months ago by cg808.
    #1245471

    Hi Chris,

    Sorry for the problem. Could you post a link to where we can see the results you are getting please? Also include admin login details in private in case we should need to access the backend of your site.

    Best regards,
    Rikard

    #1245483

    good morning rikard, thank you for getting back to me.

    #1245957

    ping :-) any updates? best chris

    #1246530

    ping :-)

    #1246754

    Hi cg808,

    Can you please make a screencast of the issue? It seems to be working fine on my end.

    Best regards,
    Victoria

    #1246827

    Hi Victoria!

    Thanks for getting back. The position indicator now works just fine on one page, but still not on the other pages.
    I’ve attached the link to where you can download the screencasts.

    Also, there is an incredible lack of responsiveness when trying to scroll the page with the non-working menu-highlight. Upon closer inspection you can see that the class active-menu-item does appear to get assigned to the correct menu-element, but gets auto-removed immediately (and so on and so forth for several times per scroll; maybe causing the performance issues).

    Since it’s now working on the one page we made content & layout changes to, I suspect it’s an issue with one or more Avia elements – but couldn’t find any meaningful difference between these pages.
    Let me know if you need any more info.

    Thanks in advance!

    #1247096

    Hi cg808,

    Best regards,
    Victoria

    #1247478
    This reply has been marked as private.
    #1248211

    Hi Victoria,
    our problem still exist :-(
    We checked the code, removed code but still the same.
    Could you please check again wit your developers.
    Thank you!
    Best Chris

    #1248788

    Hi Chris,

    Did you use the code from here?

    Best regards,
    Victoria

    #1248808

    Hi,
    Sorry for the late reply, and thanks for the login, so I copied your two pages to my localhost to test, and applied the css & javascript from the documentation and observed the menu “active-item” class being added & removed constantly.
    This seems to lead to a performance issue, as you pointed out. So I researched this and found a better working script, which I adjusted to work with the sub-menu and css.
    So the css is the same:

    /* Active menu styles */
    #top .submenu-onepage .active-menu-item,
    #top .submenu-onepage .active-menu-item a {
    background: #000 !important;
    color: #FFF !important;
    }
    
    
    
    #top .submenu-onepage .av-subnav-menu > li > a {
    border-left-style: none !important;
    border-left-width: 0px !important;
    }

    Try adding this script to the end of your functions.php file in Appearance > Editor:

    
    function custom_sub_menu_highlighting_script(){
      ?>
      <script>
    (function($){
    // Cache selectors
    var lastId,
        topMenu = $("#sub_menu1"),
        topMenuHeight = topMenu.outerHeight()+15,
        // All list items
        menuItems = topMenu.find("a"),
        // Anchors corresponding to menu items
        scrollItems = menuItems.map(function(){
          var item = $($(this).attr("href"));
          if (item.length) { return item; }
        });
    
    // Bind click handler to menu items
    // so we can get a fancy scroll animation
    menuItems.click(function(e){
      var href = $(this).attr("href"),
          offsetTop = href === "#" ? 0 : $(href).offset().top-topMenuHeight+1;
      $('html, body').stop().animate({ 
          scrollTop: offsetTop
      }, 300);
      e.preventDefault();
    });
    
    // Bind to scroll
    $(window).scroll(function(){
       // Get container scroll position
       var fromTop = $(this).scrollTop()+topMenuHeight;
       
       // Get id of current scroll item
       var cur = scrollItems.map(function(){
         if ($(this).offset().top < fromTop)
           return this;
       });
       // Get the id of the current element
       cur = cur[cur.length-1];
       var id = cur && cur.length ? cur[0].id : "";
       
       if (lastId !== id) {
           lastId = id;
           // Set/remove active class
           menuItems
             .parent().removeClass("active-menu-item")
             .end().filter("[href='#"+id+"']").parent().addClass("active-menu-item");
       }                   
    });
    })(jQuery);
    </script>
    <?php
    }
    add_action('wp_footer', 'custom_sub_menu_highlighting_script');

    In my tests this works much better and the scroll to anchor action from clicking the menu items also is much smoother, so please give this a try and if you still find a performance issue try disabling your other scripts and plugins to check for a conflict.
    In the script above it looks for the ID sub_menu1 for the sub-menu here: topMenu = $("#sub_menu1")
    This is the default ID for the first sub-menu on each page, so this should be fine, but if you use a custom ID for the sub-menu in the future please ensure to change this too.
    I also noticed that in your child theme it looks like the other script was added twice, once in the functions.php and in menu-highlight.js, after you remove the other script please ensure the new script is only added once. I’m sure that you would, I just wanted to point that out 😉

    Best regards,
    Mike

    #1248878

    Hi Mike,

    that script works perfect! As you said a lot better that the first script.
    There are no more delays or performance issues. The page is snappy and fast.

    Thank you very much for your support and help!

    Best
    Chris

    p.s. you can close this topic…

    #1248893

    Hi,
    Glad we were able to help, we will close this now. Thank you for using Enfold.

    For your information, you can take a look at Enfold documentation here
    For any other questions or issues, feel free to start new threads in the Enfold forum and we will gladly try to help you :)

    Best regards,
    Mike

Viewing 14 posts - 1 through 14 (of 14 total)
  • The topic ‘fullwidth-sub-menu one-page menu highlight stoped working :-(’ is closed to new replies.