Ydt Posted August 21, 2013 Share Posted August 21, 2013 I'm curious if there is any javascript or other possible way to disable gesture input picked up by the mobile browser. For example I'd like to use a "pinch" type gesture for a project I am working on, but while running in a mobile browser using this gesture causes the browser to zoom out and lose focus on the canvas? Any suggestions? Google search yielded negligible results. haden 1 Quote Link to comment Share on other sites More sharing options...
Chris Posted August 21, 2013 Share Posted August 21, 2013 A dirty hack to try:<script>window.ontouchstart = function(e){ e.preventDefault(); e.stopPropagation();}</script>Not tested, but should work Quote Link to comment Share on other sites More sharing options...
MikeHart Posted August 21, 2013 Share Posted August 21, 2013 Is this to be placed inside a function, the header or the body? Quote Link to comment Share on other sites More sharing options...
Chris Posted August 21, 2013 Share Posted August 21, 2013 Well, it depends. If you want to utilize touches, you just have to call preventDefault() and stopPropagation() inside your touch handler functions.If not, just define the ontouchstart method anywhere in your initialization code. Oh, I also stumbled across a notice I made for myself some time ago thats related to this question. Altough, it might be constrained to iOS - not sure. MikeHart 1 Quote Link to comment Share on other sites More sharing options...
Gio Posted August 21, 2013 Share Posted August 21, 2013 And for Microsoft devices (for IE but also if you want to build a Windows 8 app), you have to add this to the style of your html and body elements:-ms-touch-action: none; MikeHart 1 Quote Link to comment Share on other sites More sharing options...
Ydt Posted August 21, 2013 Author Share Posted August 21, 2013 A dirty hack to try:<script>window.ontouchstart = function(e){ e.preventDefault(); e.stopPropagation();}</script>Not tested, but should work Thanks! going to give it a whirl today Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.