所以我实现了一个jQuery滑动插件TouchSwipe,它让我根据特定的滑动执行jQuery事件。我有这段代码..。
$(function() { /* Swipe gestures */
//Enable swiping...
$(document).swipe( {
//Generic swipe handler for all directions
swipeRight:function(event, direction, distance, duration, fingerCount) {
$('.off-canvas-wrap').toggleClass('move-right');
>>>JQUERY EVENT SHOULD BE PLACED HERE<<<
},
swipeLeft:function(event, direction, distance, duration, fingerCount) {
$(".off-canvas-wrap").removeClass("move-right");
},
//Default is 75px, set to 0 for demo so any distance triggers swipe
threshold:0
});
}); /* End of swipe gestures script */到了'>>>Jquery event should be placed here <<<'井..。应该有一个查询事件。:)
所以我的困难来了。我找到了一个超棒的画布菜单插件(如果它被称为插件的话)在这里查看Github,-> SidebarTransitions和-> 这里的演示演示。然而,这是基于单击一个按钮。我想要执行的事件,当你点击一个单一的按钮(‘显示’,ST-效果-2,准确地说,在演示中看到)作为一个可执行的JS事件,插入滑动行的代码。
因此,在'>>>Jquery event should be placed here <<<'的部分,应该有一行或几行代码表示按钮后面的代码来打开侧边栏,因此用户可以通过滑动来打开侧边栏,而不是单击按钮。所以没有.click()或.on()。
对于SidebarTransitions的Javascript中的视图来说,它不是查看所有的脚本,而是惟一完美地执行侧栏的打开/关闭所必需的脚本。> 这里
哦,顺便说一句,关闭线(我可以把它放在不同方向的代码后面)也是很棒的!
非常感谢各位。希望你们能搞清楚,因为在过去的几个小时里,我没能做到。
JSFiddle ->> 这里! 备注:对于那些拥有多点触控板或任何滑动选项的人来说,在结果框上用一个或多个手指(我需要三个手指来滑动)滑动,你应该得到一个带有“yup”的警告,以验证你能够滑动。哦..。忽略CSS的巨大列表
发布于 2014-01-28 21:52:07
试着这样做:
$(function() { /* Swipe gestures */
//Enable swiping...
$(document).swipe( {
//Generic swipe handler for all directions
swipeRight:function(event, direction, distance, duration, fingerCount) {
$('.off-canvas-wrap').toggleClass('move-right');
$('[data-effect="st-effect-2"]').trigger('click');
},
swipeLeft:function(event, direction, distance, duration, fingerCount) {
$(".off-canvas-wrap").removeClass("move-right");
},
//Default is 75px, set to 0 for demo so any distance triggers swipe
threshold:0
});
}); /* End of swipe gestures script */https://stackoverflow.com/questions/21417586
复制相似问题