@andxor/jquery-ui-touch-punch-fix

中文文档
1.0.2发布于 2019/10/03(MIT OR GPL-2.0)CommonJS近 30 天下载 2240

Touch Event Support for jQuery UI + detection fix

原始使用文档

jQuery UI Touch Punch

Touch Event Support for jQuery UI

jQuery UI Touch Punch is a small hack that enables the use of touch events on sites using the jQuery UI user interface library.

Visit the official Touch Punch website.

Currently, jQuery UI user interface library does not support the use of touch events in their widgets and interactions. This means that the slick UI you designed and tested in your desktop browser will fail on most, if not all, touch-enabled mobile devices, becuase jQuery UI listens to mouse events—mouseover, mousemove and mouseout—not touch events—touchstart, touchmove and touchend.

That's where jQuery UI Touch Punch comes in. Touch Punch works by using simulated events to map touch events to their mouse event analogs. Simply include the script on your page and your touch events will be turned into their corresponding mouse events to which jQuery UI will respond as expected.

As I said, Touch Punch is a hack. It duck punches some of jQuery UI's core functionality to handle the mapping of touch events. Touch Punch works with all basic implementations of jQuery UI's interactions and widgets. However, you may find more complex cases where Touch Punch fails. If so, scroll down to learn how you can file and/or fix issues.

This code is dual licensed under the MIT or GPL Version 2 licenses and is therefore free to use, modify and/or distribute, but if you include Touch Punch in other software packages or plugins, please include an attribution to the original software and a link to this Touch Punch website.

Using Touch Punch is as easy as 1, 2…

Just follow these simple steps to enable touch events in your jQuery UI app:

  1. Include jQuery and jQuery UI on your page.

    <script src="http://code.jquery.com/jquery.min.js"></script>
    <script src="http://code.jquery.com/ui/1.8.17/jquery-ui.min.js"></script>
    
  2. Include Touch Punch after jQuery UI and before its first use.

    Please note that if you are using jQuery UI's components, Touch Punch must be included after jquery.ui.mouse.js, as Touch Punch modifies its behavior.

    <script src="jquery.ui.touch-punch.min.js"></script>
    
  3. There is no 3. Just use jQuery UI as expected and watch it work at the touch of a finger.

    <script>$('#widget').draggable();</script>
    

Tested on iPad, iPhone, Android and other touch-enabled mobile devices.

版本与发布记录

@andxor/jquery-ui-touch-punch-fix 共发布 2 个版本,首次发布于 2019/10/03;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.0.2latest2019/10/037 年前
1.0.12019/10/037 年前

关于 @andxor/jquery-ui-touch-punch-fix 的常见问题

@andxor/jquery-ui-touch-punch-fix 是什么?

Touch Event Support for jQuery UI + detection fix

如何安装 @andxor/jquery-ui-touch-punch-fix?

在项目目录运行 npm install @andxor/jquery-ui-touch-punch-fix,或使用 pnpm add / yarn add / bun add。

@andxor/jquery-ui-touch-punch-fix 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/andxor__jquery-ui-touch-punch-fix 是否存在。

@andxor/jquery-ui-touch-punch-fix 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@andxor/jquery-ui-touch-punch-fix 可以商用吗?

@andxor/jquery-ui-touch-punch-fix 使用 (MIT OR GPL-2.0) 许可。可在 MIT、GPL-2.0 中任选其一遵守。选择 MIT 时,宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@andxor/jquery-ui-touch-punch-fix 的下载量有多少?

根据 npm 官方下载统计,@andxor/jquery-ui-touch-punch-fix 在 2026/10/06 – 2026/11/04 这 30 天内被下载 2,240 次,日均约 75 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@andxor/jquery-ui-touch-punch-fix 还在维护吗?

最新版本 1.0.2 发布于 2019/10/03(7 年前);至今共发布 2 个版本,其中过去 12 个月发布了 0 个;首次发布于 2019/10/03。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。