简体   繁体   English

缩放或转动移动浏览器

[英]Zooming or wheeling on a mobile browser

In a desktop browser, I detect the mouse wheel use with the standard mousewheel or DOMMouseScroll events. 在桌面浏览器中,我使用标准鼠标滚轮或DOMMouseScroll事件检测鼠标滚轮的使用情况。 I can thus change a canvas (zooming in a kind of map). 因此我可以更改画布(放大一种地图)。

Now I want to bring this feature to my mobile users : I need to intercept the standard pinch-zoom gestures (without zooming the page). 现在我想将这个功能带给我的移动用户:我需要拦截标准的缩放缩放手势(不缩放页面)。 Is that possible today ? 今天有可能吗? Is it possible to get the center of the gesture (for localized zoom and unzoom) ? 是否可以获得手势的中心(用于本地化缩放和取消缩放)?

Note that it needs to work on the standard browser of Android 4.2. 请注意,它需要在Android 4.2的标准浏览器上运行。 Other browsers/devices aren't in the scope of this question, which may make it easier. 其他浏览器/设备不在此问题的范围内,这可能会使其更容易。

This seems fixed on 3.0 . 这似乎固定在3.0 This is a test page that seems to work on my ICS tablet. 这是一个似乎可以在我的ICS平板电脑上运行的测试页面 This is an excerpt from the linked test page: 这是链接测试页面的摘录:

// Touch events seem to work in iOS, Android browser 3.0 and up,
// and various 3rd-party Android browsers, now including FireFox
// (Nightly as of 03-Feb-2012, not enabled by default yet).
eventTarget.addEventListener('touchstart', HandleTouchStart, false);
document.addEventListener('touchmove', HandleTouchMove, false);
document.addEventListener('touchend', HandleTouchEnd, false);
document.addEventListener('touchcancel', HandleTouchCancel, false);

这个问题的答案指向一个可能有用的库(Hammer.js): 如何在javascript中检测android pinch zoom

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM