mui 关闭导航侧滑及点击菜单之外区域关闭

//阻止侧滑导航
document.getElementsByClassName('mui-inner-wrap')[0].addEventListener('drag',function(event) {
	event.stopPropagation();
});
// 添加menu点击显示菜单
mui('body').on( 'tap' , '#openMenu' , function(){
	mui('.mui-off-canvas-wrap').offCanvas('show');
})
//添加除导航按钮和导航展开区域外点击关闭菜单
mui(document).on( 'tap' , 'body' , function(e){
    var btn = $(".mui-off-canvas-right");   // 设置目标区域(展开菜单区域)
    var menu = $("#openMenu");//设置目标区域(打开菜单按钮)
    if (!btn.is(e.target) && btn.has(e.target).length === 0 &&!menu.is(e.target) &&menu.has(e.target).length === 0) {
	   mui('.mui-off-canvas-wrap').offCanvas().close();
      }
});

 

你可能感兴趣的:(mui)