在使用 $("#panel").panel("open");
打开面板之前,我想检测用户是否从边缘滑动。这是代码
$("#main").on("swiperight",function(event){
var data = event.originalEvent.touches ? event.originalEvent.touches[0] : event,
coords = [data.pageX, data.pageY];
console.log(coords);
});
但是 coords
没有返回任何东西,因为我得到了错误:
Uncaught TypeError: Cannot read property 'touches' of undefined
那么滑动发生时有没有办法获取坐标?
或者有没有一种简单的方法可以检测凝视位置是否来自 改为左边缘?
谢谢。
最佳答案
在 jqm 1.4+ 中尝试以下,对我有用,相应地调整边缘 trim 值,50 对我来说很好
$( "div.ui-page" ).on( "swiperight", function( e ) {
if ( e.swipestart.coords[0] <50) {
// your logic
}
});
这是 x 坐标,同样你可以从 coords[1] 得到 y
关于javascript - 在 jQuery Mobile 中检测从边缘滑动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20109508/