I was just wondering if we have a specific library or framework built on the closure-library , which is specifically designed for to开发者_运维百科uch devices(Android or Ipad). I already have my web-app using the closure-library, now want to maintain consistency for the mobile touch devices or tablets.
There are many other frameworks or plugins for other libraries like: http://www.sencha.com/products/touch/ -- (Ext.js) http://jqtouch.com/ -- (jquery)
Do we have something similar for the closure-library. Can somebody please help me on this.
As far as I know the plain TOUCH events are already defined
/**
* Constants for event names.
* @enum {string}
*/
goog.events.EventType = {
...
// WebKit touch events.
TOUCHSTART: 'touchstart',
TOUCHMOVE: 'touchmove',
TOUCHEND: 'touchend',
TOUCHCANCEL: 'touchcancel',
}
But there is no gesture-recognizer.
If you use the gestures Webkit(Safari) fires, you will have to create your own externs file.
https://developer.apple.com/library/iad/documentation/UserExperience/Reference/GestureEventClassReference/index.html#//apple_ref/javascript/cl/GestureEvent
If you download the touch library from jQueryMobile's site. Just build jQueryMobile only with their touch library. Import that into your project. Then have a map like I did...
var hasTouch = 'ontouchstart' in window;
var humanEvents = {
DOWN: (hasTouch) ? goog.events.EventType.TOUCHSTART : goog.events.EventType.MOUSEDOWN,
OVER: (hasTouch) ? goog.events.EventType.TOUCHSTART : goog.events.EventType.MOUSEOVER,
MOVE: (hasTouch) ? goog.events.EventType.TOUCHMOVE : goog.events.EventType.MOUSEMOVE,
UP: (hasTouch) ? goog.events.EventType.TOUCHEND : goog.events.EventType.MOUSEUP,
OUT: (hasTouch) ? goog.events.EventType.TOUCHEND : goog.events.EventType.MOUSEOUT,
CLICK: (hasTouch) ? "tap" : goog.events.EventType.CLICK
};
精彩评论