New Landing How can we help? Themeforest Theme Support Dante Programatically close mobile menu

Viewing 4 posts - 1 through 4 (of 4 total)
  • Posted in: Dante
  • #65096
    klassicd
    Member
    Post count: 4

    I am intercepting clicks on the header menu to implement a smooth scroll effect for a single page website. The mobile menu does not close when I intercept clicks and return false. Is there a javascript function or a set of CSS rules I can apply to close the mobile menu?

    #65182
    Kyle – SUPPORT
    Moderator
    Post count: 35880

    Hi

    Are you using the latest version of the theme?

    – Kyle

    #65383
    klassicd
    Member
    Post count: 4

    I’m using version 2.1.

    There was a smooth-scroll-link class function in version 2.1. The problem I had with this function is it wouldn’t update the nav-line styling.

    It also wouldn’t handle partial single page websites. If you want to see what I mean check out skipthelinevegas.com. The navigation has a smooth scroll effect on the homepage, but if you visit Terms & Conditions the navigation will still work. Your class function only worked for links pointing to same page they were on.

    My issue is with the mobile menu though. Check out the site on your phone. If you click a mobile menu link it does the smooth scroll effect but the menu stays open. I was hoping there was a javascript function I could use to close the mobile menu without having to mess with css styles.

    
    // intercept menu clicks
    jQuery('.menu-item a').click(function(){
            // link points to an anchor on the same page. update nav-line style and scroll to content
            if (window.location.pathname) {
                // hide nav-line for all menu items
                jQuery('.nav-line').hide();
    
                // show nav-line on this link clicked
                jQuery(this).children('.nav-line').show();
    
                // get name of anchor and scroll to content
                var anchor = jQuery(this).attr('href').substr(1);
                scrollSkip(anchor);
    
                return false;
            } else {
                // link does not point to an anchor on the same page. redirect page normally.
                return true;
            }
        });
    
    // modified version of your internally scrolling function 
    function scrollSkip(linkHref)
    {
        var spacerHeight = jQuery(linkHref).height(),
            headerHeight = 0;
    
        if (jQuery('.sticky-header').length > 0) {
            headerHeight = jQuery('.sticky-header').height();
        }
        if (jQuery('#wpadminbar').length > 0) {
            headerHeight = headerHeight + 28;
        }
    
        jQuery('html, body').stop().animate({
            scrollTop: jQuery(linkHref).offset().top + spacerHeight - headerHeight
        }, 1000, 'easeInOutExpo');
    }
    #65417
    Kyle – SUPPORT
    Moderator
    Post count: 35880

    Hi

    We fixed this in version 2.51

    – Kyle

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in and have valid license to reply to this topic.

License required for one of the following items
Login and Registration Log in · Register