0

我已经在jsFiddle上设置了我的问题的这个例子:也可以全屏查看它,因为这个例子是响应式的:

当我在激活 mmenu 时单击菜单项后会发生什么,滚动跳转到随机锚点,而不是正确的锚点。有人可以帮忙吗?

我有 jquery 1.9.1、mmenu.js 和 jqueryeasing,这些是内联脚本

$(function() {
            $('nav ul li a').bind('click',function(event){
                var $anchor = $(this);
                $('html, body').stop().animate({
                    scrollTop: $($anchor.attr('href')).offset().top
                }, 1000,'easeInOutExpo');
                event.preventDefault();
            });
        });



        $(function() {
            $('nav#nav').mmenu({
                configuration: {
                    //  For some odd reason, the header won't stay "fixed"
                    //  when using hardware acceleration
                    hardwareAcceleration: false
                }
            });
        });
4

1 回答 1

2

没有人回答,但我想分享修复。mmenu 的创建者 Fred 非常友好地通过电子邮件提供了一些支持,您可以在此处查看修复:http: //jsfiddle.net/9FdXv/8/

这里的js:

$(function() {
            $('nav ul li a').bind('click',function(event){
                var $anchor = $(this);

                $('nav#nav').one('closed.mmenu', function() {
                    setTimeout(function() {
                        $('html, body').stop().animate({
                            scrollTop: $($anchor.attr('href')).offset().top
                        }, 1000,'easeInOutExpo');
                    }, 10);
                });
                $('nav#nav').trigger('close.mmenu');

                event.preventDefault();
                event.stopImmediatePropagation();
            });
        });



        $(function() {
            $('nav#nav').mmenu({
                configuration: {
                    //  For some odd reason, the header won't stay "fixed"
                    //  when using hardware acceleration
                    hardwareAcceleration: false
                }
            });
        });

希望这对其他人有帮助

于 2013-07-01T11:05:16.830 回答