javascript - Detecting pinching in desktop browsers -


so scrolling events can detect panning gestures in desktop browsers , modify content accordingly. there way detect pinching (zooming) gestures? instead of browser zooming whole site (or not doing anything) modify dom element accordingly.

there laptops such trackpads (like magic trackpad , force touch trackpad). gestures can captured, how can use them in desktop web apps?

imagine pinch , zoom in our out in google map in desktop browser. , pan left , right hand gesture.

i suggest using specialized library hammer.js. have @ this example of hammer.js documentation, utilize pinch gesture recognition.

according example detecting pinch gesture simple as:

var myelement = document.getelementbyid('myelement'),     mc = new hammer.manager(myelement),     pinch = new hammer.pinch();  mc.add(pinch); mc.on("pinch", function(ev) {     console.log('you sir did pinch!'); }); 

however, if wanted react changing viewport within layout, might better off using responsive design features media queries.


edit: not work way. thats because desktop browsers not yet support gesture events. second part of answer remains true: can use media queries based on viewport dimensions , hook in on resize events of window usual.


Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -