How To Make Off Canvas Menu Close Helix Ultimate 2.1.1 - Question | JoomShaper

How To Make Off Canvas Menu Close Helix Ultimate 2.1.1

Ralph-Uwe Scherer

Ralph-Uwe Scherer

Helix Framework 11 months ago

I just tried the following custom javascript code in my Helix Ultimate 2.1.1 template but it still does not make the Off Canvas menu disappear when clicking on any of the links.

jQuery(function ($) { $(".offcanvas-menu a").on("click", function () { $(".off-canvas-menu-init").removeClass("offcanvas slide-top-menu full-screen-off-canvas full-screen-ftop new-look-off-canvas"); $(".offcanvas-overlay").remove(); }); });

See page here: https://ids.cdsvc.com/ Click on any of the Off Canvas links and you will see what I am talking about.

Any other ideas? I am using Chrome on a Mac but have also tested on Safari and it behaves the same way.

0
3 Answers
Atick Eashrak Shuvo
Atick Eashrak Shuvo
Accepted Answer
Support Agent 11 months ago #175953

Hello There,

Apologize for the issue you're experiencing. Please add the following JS code to your Template Options -> Custom Code -> Custom JavaScript

$(document).on('click', '.offcanvas-menu a[href*="#"]', function (event) {
    const targetHref = $(this).attr('href');

    if (targetHref.includes('#')) {
        event.preventDefault();

        const hash = targetHref.split('#')[1];
        const targetElement = $(`#${hash}`);

        if (targetElement.length) {
            $('html, body').animate({ scrollTop: targetElement.offset().top }, 500);
        }

        $('.offcanvas-init').removeClass('offcanvas-active full-offcanvas');
    }
});

This should resolve the problem. Please let us know if you need any further assistance!

Best regards

0
Ralph-Uwe Scherer
Ralph-Uwe Scherer
Accepted Answer
11 months ago #176079

Thank you! That worked perfectly. Onward and upward we go.... ;-)

0
Atick Eashrak Shuvo
Atick Eashrak Shuvo
Accepted Answer
Support Agent 11 months ago #176088

You are welcome. Please marked the issue as solved.

0