如何在IPAD中启用/禁用滚动切换菜单?

时间:2018-09-27 10:11:09

标签: javascript

我在打开切换菜单时尝试禁用移动大小的正文滚动,但是现在我在IPAD中遇到问题,我的菜单不再可滚动,如何启用/禁用菜单滚动?

   $('.js-mobil-navigator').on('click', function () {
        // this is to prevent page scroll problem in iOS
        if ($('body').hasClass('nav-open')) {
            toggleNavigationMenu(false);
        } else {
            toggleNavigationMenu(true);
        }
    });
    $('.outer-wrapper').on('click', function () {
        toggleNavigationMenu(false);
    });
    function toggleNavigationMenu(open) {
        // when navigation menu is open, add position fixed to the body
        // otherwise, set the body and html position back to initial
        // this is to prevent page scroll problem in iOS
        if (open) {
            $('body').addClass('nav-open');
            jQuery('body, html').css('position', 'fixed');
        } else {
            $('body').removeClass('nav-open');
            jQuery('body, html').css('position', 'initial');
        }
     
    }

0 个答案:

没有答案