单页网站上的jquery mmenu.js

时间:2013-06-27 08:56:03

标签: jquery mobile menu navigation

我在jsFiddle上设置了我的问题示例: 也是全屏查看,因为示例是responsive

当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
                }
            });
        });

1 个答案:

答案 0 :(得分:2)

没有人回答,但我想分享修复。 mmenu的创建者弗雷德非常友好地通过电子邮件提供一些支持,你可以在这里看到修复: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
                }
            });
        });

希望这有助于其他人