Question

in an project I do use mmenu first time. It works as expected but there is one thing I would love to have working, but it still isn't :/

Here's the URL: http://1pager.gut-entwickelt.de/

What I would love to see: After selecting an menu-point, it shouldn't scroll within milliseconds. It should wait till the menu is closed, then start scrolling.

Thatfor I added this script-part:

Me.mobileMenu.mmenu({
        zposition: "front",
        onClick:   {
            preventDefault: true,
            setSelected   : false
        }
    });

    Me.mobileMenu
    .find('a')
    .on(
        'click',
        function() {
            var href = $(this).attr('href');

            if (Me.mobileMenu.hasClass('mm-opened')) {
                Me.mobileMenu
                    .off('closed.mm')
                    .one(
                        'closed.mm',
                        function() {
                            setTimeout(
                                function(){
                                    $('html, body').animate({
                                        scrollTop: $(href).offset().top
                                    });
                                }, 
                                1000
                            );

                            return false;
                        }
                    );
            } else {
                setTimeout(
                    function(){
                        $('html, body').animate({
                            scrollTop: $(href).offset().top
                        });
                    },
                    1000
                );
            }
            return false;
        }
    );

This seems to work here: http://mmenu.frebsite.nl/examples/responsive/index.html But on that page it don't... any ideas?

Regards, Oliver Lippert

Was it helpful?

Solution

The "closed" event is triggered when the menu finished closing, so you shouldn't need an extra timeout. Have a look at this example, it's a bit more straightforward: http://mmenu.frebsite.nl/mmenu/demo/onepage.html

OTHER TIPS

Extended to Fred's reply I had another JS-code for doing the scroll. After disabling it, now the menu closes first, and the Scroll starts later.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top