推荐jQuery添加Webkit的触摸的方法
发布时间:2023-10-03 15:06:15 所属栏目:教程 来源:
导读:这段代码是我在做13年一份兼职的时候无聊加上去的,为jQuery添加触摸事件的支持。因为做得有点无聊,所以就帮客户添加了用响应式网页+JS touch兼容了移动设备,主要是Webkit的移动设备。
这里就分享下我的实现。
这里就分享下我的实现。
这段代码是我在做13年一份兼职的时候无聊加上去的,为jQuery添加触摸事件的支持。因为做得有点无聊,所以就帮客户添加了用响应式网页+JS touch兼容了移动设备,主要是Webkit的移动设备。 这里就分享下我的实现。 先贴上代码: 代码如下: //Published by Indream Luo //Contact: indreamluo@qq.com //Version: Chinese 1.0.0 !function ($) { window.indream = window.indream || {}; $.indream = indream; //Define events indream.touch = { evenList: { touchStart: { htmlEvent: 'touchstart' }, touchMove: { htmlEvent: 'touchmove' }, touchEnd: { htmlEvent: 'touchend' }, tapOrClick: { eventFunction: function (action) { $(this).each(function () { (function (hasTouched) { $(this).touchEnd(function (e) { hasTouched = true; action.call(this, e); }); $(this).click(function (e) { if (!hasTouched) { (编辑:聊城站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐