jquery-mobile - 如何在 jQuery Mobile 中定义不可滑动的区域?
解决方案
有不止一种可能的解决方案来实现你所要求的。
和swipe
是自定义swipeleft
jQuery swiperight
Mobile 事件。JQM 为这些事件附加了一个自定义结构,其中包含原始触摸事件的开始和停止坐标。
首先,如果你想自己处理滑动,你需要告诉框架:
跳过内置面板滑动处理程序:
<div data-role="panel" id="myPanel" data-swipe-close="false">
之后,要打开或关闭panel
,您可以简单地检查 的坐标touchstart
,touchend
或同时检查两者(由您决定)。
触摸事件的自定义处理:
$('body').on('swiperight', function (e) {
var startX = e.swipestart.coords[0],
stopX = e.swipestop.coords[0];
if(startX < 100) {
$('#myPanel').panel('open');
}
});
$('body').on('swipeleft', function (e) {
var startX = e.swipestart.coords[0],
stopX = e.swipestop.coords[0];
if(stopX < 100) {
$('#myPanel').panel('close');
}
});
如果您想要更系统的方法,您还可以检查一些相关panel
选项:
var data = $('#myPanel').data("mobile-panel"),
display = data.options.display, /* Panel Type: reveal, push, overlay */
position = data.options.position; /* Panel position: left, right */
并相应地微调滑动动作(或任何你想要的)。
推荐阅读
- python - 使用python将文件夹中具有特定结尾的文件列为变量
- python - 使用子进程将“jq”输出发送到文件
- android - 如何在运行时使用 kotlin 在站点中添加数据?
- javascript - Firebase Angular 7 身份验证持久性
- dspace - 如何在 dspace 中使用 rest-api 注册电子人
- php - 使用 PHP Swiftmailer 时,我们如何解决错误 554 5.5.1(无有效收件人)?
- vb6 - 使用 vb6 通过 MSFlexigrid 将 XML 数据导入 SQL 表
- facebook - facebook api图不搜索用户
- c++ - 为什么隐式转换为 std::string 不适用于 operator<< 被调用
- assembly - 箭头击中数字游戏。箭头未击中定义的数字