简体   繁体   中英

Zooming or wheeling on a mobile browser

In a desktop browser, I detect the mouse wheel use with the standard mousewheel or DOMMouseScroll events. 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. Other browsers/devices aren't in the scope of this question, which may make it easier.

This seems fixed on 3.0 . This is a test page that seems to work on my ICS tablet. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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