Tagged: ,

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #452455

    Hello,

    We use Enfold for a one-page site and modified the menu to always show the mobile menu floating in the top left corner. The problem is that when you click on the menu, you’re always taken to the top of the page since there’s a ‘#’ link when you open and close the menu.

    Is the a way to remove the ‘#’ link or change anything else, so that you stay where you are on the page when you click on the menu?

    Thanks!

    #453271

    Hi PG!

    You could try commenting out line 444 in the /enfold/js/avia.js file.

    win.scrollTop(0);
    

    But you will probably need to add some CSS to the mobile menu so it gets a fixed position like how your currently doing. Also keep in mind that this will not let you scroll down in case the menu is long or the screen very small.

    Cheers!
    Elliott

    #453275

    Hey PG!

    via FTP go to Enfold->includes and open helper-main-menu.php, find this code on line 16:

    if($responsive)
    {
    echo '<a id="advanced_menu_toggle" href="#" '.av_icon_string('mobile_menu').'></a>';
    echo '<a id="advanced_menu_hide" href="#" 	'.av_icon_string('close').'></a>';
    }
    

    and replace it with this:

    if($responsive)
    {
    echo '<a id="advanced_menu_toggle" href="" '.av_icon_string('mobile_menu').'></a>';
    echo '<a id="advanced_menu_hide" href="" 	'.av_icon_string('close').'></a>';
    }
    

    Hope this helps.

    Regards,
    Andy

    • This reply was modified 9 years, 4 months ago by Andy.
    #453364

    Thanks a lot for the suggestions, Elliott and Andy.

    Unfortunately none of these solve the problem.

    I had already tried it without ‘win.scrollTop(0);’ before, nothing changes.

    And changing the helper-main-menu.php file doesn’t help either. In addition I tried it with href=”javascript:void(0);” and a few other things, nothing changes and I’m always taken to the top of the page before the menu opens.

    It seems like the # anchor isn’t the problem here.

    Do you have any other suggestions?

    Thanks!

    #453943

    Hi!

    When I comment out that line on my XAMPP setup it does not jump anymore but the menu stays to the top so it would require some CSS to give it a fixed position, etc etc.

    I was thinking you would need to add the function(e) { e.preventDefault(); } to prevent the link behaviour from jumping to the top but just commenting out that line I posted seems to work on my end.

    Did you clear your browser cache and any caching related plugins you might have installed?

    Best regards,
    Elliott

    • This reply was modified 9 years, 4 months ago by Elliott.
    #577035

    hy,
    i just found this post as i also want to disable the scrollTop-functionality. i am concerned to use your suggested methods, as i guess it will be discarded on theme update?
    do you have any idea on how to hook into this functionality with an own js-function or anything else?

    thanks,
    matt

    #577051

    hy again :)

    i found a workaround with js-only in my child theme:
    var savedPos = 0;
    jQuery(‘#advanced_menu_toggle’).click(function(e){
    savedPos = jQuery(window).scrollTop();
    });
    jQuery(‘#advanced_menu_hide’).click(function(e){
    setTimeout(function(){ jQuery(window).scrollTop(savedPos); }, 1000);
    });

    the timeout is necessary, as it works only when the mobile menu is completely hidden. do you know any callback i could use to make this more robust?

    thanks
    matt

    #578201

    Hey!

    Sorry, I do not know of one. Glad you got it sorted.

    Regards,
    Elliott

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