用于移动捏/缩放操作的 javascript 事件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8509799/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 03:39:25  来源:igfitidea点击:

javascript event for a mobile pinch/zoom action

javascriptmobile

提问by Jose

I need some help. I am trying to work on a mobile web page. What i'm trying to do is "capture" when the user does a zoom in/zoom out action. That is, when they put two fingers on screen and separate or close their fingers together. I looked at jquery mobile and didn't see it.

我需要一些帮助。我正在尝试处理移动网页。当用户执行放大/缩小操作时,我想做的是“捕获”。也就是说,当他们将两根手指放在屏幕上并分开或合拢手指时。我看着jquery mobile并没有看到它。

So specifically can I attach a javascript function to a pinch/zoom event in a mobile device?

那么具体来说,我可以将 javascript 函数附加到移动设备中的捏/缩放事件吗?

Any help would be greatly appreciated.

任何帮助将不胜感激。

回答by Nachiketha

hammer.js http://eightmedia.github.com/hammer.js/is one of the best javascript library for such problems..

hammer.js http://eightmedia.github.com/hammer.js/是解决此类问题的最佳 javascript 库之一。

回答by psema4

Zeptois a jquery compatible library for mobile and provides handlers for pinch events. Unfortunately, they are listed as iOS only. (See "Touch Events")

Zepto是一个适用于移动设备的 jquery 兼容库,并为捏合事件提供处理程序。不幸的是,它们仅作为 iOS 列出。(参见“触摸事件”)

Synopsis:

概要:

$('some selector').pinch(function(){ ... });
$('some selector').pinchIn(function(){ ... });
$('some selector').pinchOut(function(){ ... });

回答by fisherwebdev

Touchyis a jQuery plugin that provides support for pinch, drag, swipe, longpress, rotate. It works on any browser that implements touchstart, touchmove and touchend. Future versions will also support IE10.

Touchy是一个 jQuery 插件,提供对捏、拖动、滑动、长按、旋转的支持。它适用于任何实现 touchstart、touchmove 和 touchend 的浏览器。未来的版本也将支持 IE10。