简体   繁体   English

html5支持触控手机吗?

[英]Does html5 support touch on mobile phones?

I was wondering if html5 is supporting touch functionality on a mobile device native? 我想知道html5是否支持移动设备原生的触摸功能? So we don't have to make an native app for iOS/Android/WP7 but can make an html5 page which loads in the mobile browser. 因此,我们不必为iOS / Android / WP7制作本机应用程序,但可以制作在移动浏览器中加载的html5页面。

EDIT 编辑

I mean the JavaScript support for touch native in the browser so you can do you own thing with the touch in html5. 我的意思是在浏览器中支持touch native的JavaScript支持,这样你就可以通过html5中的触摸实现自己的功能。

Depends on the type of touch event. 取决于触摸事件的类型。 For your standard browser click/mouse events these are emulated by the browser. 对于标准浏览器单击/鼠标事件,这些事件由浏览器模拟。 As mentioned by Halst, just make your clickable elements big enough to work in a mobile environment. 正如Halst所提到的,只需使您的可点击元素足够大,即可在移动环境中工作。

If you want to use multitouch/gestures, it gets a little more interesting. 如果你想使用多点触控/手势,它会变得更有趣。

Webkit provides touchstart, touchmove, touchend, touchcancel . Webkit提供touchstart, touchmove, touchend, touchcancel For single touch events support should be the same in both IOS Safari and Android Webkit. 对于单点触摸事件,IOS Safari和Android Webkit中的支持应该相同。 You could roll your own or use a library like jqTouch . 您可以自己滚动或使用像jqTouch这样的库。

You can read more on how IOS Safari handles touch events . 您可以阅读有关IOS Safari如何处理触摸事件的更多信息 Events for Android don't seem to be as well documented, but you can read more on quirksmode touch support . Android的事件似乎没有详细记录,但您可以阅读有关quirksmode触摸支持的更多信息。

只需使笑和按钮足够大,就是这样。

Somewhat. 有些。

It's possible to write a webpage that looks almost as a native app for iPad (including multi-touch) but I had to give up with using "high level" events and had to handle instead the touches array explicitly to get a reasonable zoom/pan. 可以编写一个看起来几乎像iPad的本机应用程序的网页(包括多点触控),但我不得不放弃使用“高级”事件,而是必须明确处理touches数组以获得合理的缩放/平移。 The results are IMO quite good (people I've shown that vector graphics editor toy thought it was a native app). 结果是IMO相当不错(人们我已经证明了矢量图形编辑器玩具认为它是一个原生应用程序)。

For Android however things are a little trickier because on my Nexus one apparently there is no way to get anything close to full-screen (and for a phone losing the address bar space means losing a LOT of space) and also multitouch is disabled in the default browser :-( 对于Android而言事情有点棘手,因为在我的Nexus上显然没有办法让任何接近全屏的东西(对于失去地址栏空间的手机意味着失去很多空间)而且多点触控在默认浏览器 :-(

Both problems (fullscreen and multitouch) are however solved for example in Opera and this is in my opinion sad because (may be) this means they don't WANT good web apps on the phone... 然而,例如在Opera中解决了这两个问题(全屏和多点触控),这在我看来很难过,因为(可能)这意味着他们不想在手机上使用好的网络应用程序......

So technically it's possible to write a single html5/js program that runs in both desktop and phone, but this doesn't of course mean that the best UI for a desktop app is also the best for a phone. 所以从技术上来说,可以编写一个在桌面和手机上运行的单个html5 / js程序,但这当然不意味着桌面应用程序的最佳用户界面也是手机的最佳用户界面。

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

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