Javascript 在刷卡时打开导航抽屉(Material Design Lite)
我正在使用Material Design Lite为web视图中的应用程序创建UI,但是我遇到了一个问题,无法在滑动时部署导航抽屉 我使用这个jquery代码来识别刷卡事件Javascript 在刷卡时打开导航抽屉(Material Design Lite),javascript,jquery,swipe-gesture,material-design-lite,Javascript,Jquery,Swipe Gesture,Material Design Lite,我正在使用Material Design Lite为web视图中的应用程序创建UI,但是我遇到了一个问题,无法在滑动时部署导航抽屉 我使用这个jquery代码来识别刷卡事件 $(function() { $("#test").swipe( { //Generic swipe handler for all directions swipeRight:function(event, direction, distance, duratio
$(function() {
$("#test").swipe( {
//Generic swipe handler for all directions
swipeRight:function(event, direction, distance, duration, fingerCount) {
$(this).text("Event Triggered" );
},
});
});
从这里我不知道如何打开导航抽屉。我更喜欢整个屏幕“可切换”,尤其是左边缘。触发此滑动处理程序时,如何打开导航栏?我试图在演示材料design lite中添加此效果。因此,我找到的解决方案是通过material design lite生成的类“mdl-layout\uuu drawer-button”模拟汉堡按钮的点击事件
$(function() {
$("#test").swipe( {
//Generic swipe handler for all directions
swipeRight:function(event, direction, distance, duration, fingerCount) {
$(".mdl-layout__drawer-button").click();
},
});
});
打开/关闭sidenav
document.querySelector('.mdl layout').MaterialLayout.toggleDrawer()代码>能否请您重新编写您的答案,以满足开场白的需要,而不是只处理您自己网站的一些代码。这将有助于开场白和其他读者,因为他们可以理解你的意思。这个解决方案非常有效,我已经对它进行了编辑,以适合我在原始文章中使用的示例。ThanksHow您是否在MDL中使用滑动手势?它似乎不支持开箱即用的手势。