Using goog.events.listen for touch events

465 views
Skip to first unread message

Andrew Mattie

unread,
Oct 21, 2010, 8:21:17 PM10/21/10
to closure-lib...@googlegroups.com
Unless I'm missing something, it appears that goog.events.listen isn't very well suited for dealing with touchstart, touchmove, and touchend. The reason for this is that the actual event gets wrapped in a goog.events.BrowserEvent object as a proxy, destroying non-standard properties such as 'touches', 'changedTouches', and 'targetTouches', 'scale', and 'rotation' on the event itself. See <http://code.google.com/p/closure-compiler/source/browse/trunk/externs/iphone.js> and <http://developer.apple.com/library/safari/#documentation/UserExperience/Reference/TouchEventClassReference/TouchEvent/TouchEvent.html> for references to those properties.

Adding those properties into the goog.events.BrowserEvent fixes the issue. Should I submit a patch, or is there a more preferred way of handling this?

Nick Santos

unread,
Oct 22, 2010, 11:12:08 AM10/22/10
to closure-lib...@googlegroups.com

For rarely-accessed event properties, we often just use BrowserEvent's
getBrowserEvent method to get the underlying native event object. See
goog.events.MouseWheelHandler for a good example of this.

Best,
Nick

Reply all
Reply to author
Forward
0 new messages