Yes, it may have value. Consider writing a plugin.
The pointer events spec[1] may be of interest, as things like
tap/slide/pinch are all non-standard.
I did this exact same thing [2] for Windows Phone 7, as there aren't even
mouse events.
There are numerous things you need to be aware of when creating the event,
like the current zoom/scale of the page, + any panning, scrolling, css3
translations.
You also need to consider the way all DOM events bubble from the element to
the document and back up.
IMHO, Implementing this correctly is not for the faint of heart, and your
work may be negated at any time by a new browser.

Cheers,
  Jesse

[1]
http://www.w3.org/TR/pointerevents/
[2]
https://github.com/purplecabbage/cordova-wp7/blob/master/templates/standalone/cordovalib/BrowserMouseHelper.cs


@purplecabbage
risingj.com


On Thu, Apr 18, 2013 at 10:08 AM, jbo...@openmv.com <jbo...@openmv.com>wrote:

> On the short them, it would help solve 'Android fragmentation' problems:
>
> https://github.com/android/platform_frameworks_base/blob/android-cts-4.0.3_r2/core/java/android/webkit/WebView.java#L6044
>
>
> https://github.com/android/platform_frameworks_base/blob/master/core/java/android/webkit/WebViewClassic.java#L5824
>
> Android doesn't exactly pass the touchstart etc.. events to webkit the
> same way and more importantly with the same delays. Not to mention, some
> versions have bugs (missing touchend, touchmove events).
> If coding a pure HTML/javascript app, you can avoid the 'native' onTouch()
> processing and pass events faster to your app.
>
> It's an educated guess at the moment, but I'm quite sure performance /
> response time for the user on all platforms will be better if the gesture
> detection is done on the native side.
>
> On the long term, I don't see how JavaScript libraries would allow (within
> reasonable ms) for more complex 'gesture' detection. I would rather do
> something like:
> webView.addGesture('swipe');
> webView.addGesture('handgrab');
> onTouch/Gesture:
> // do gesture detection in native code
>    webView.sendJavascript("cordova.fireEvent('handgrab', {node, ...}");
>
>
> -----Original Message-----
> From: Filip Maj [mailto:f...@adobe.com]
> Sent: Wednesday, April 17, 2013 12:47 PM
> To: dev@cordova.apache.org
> Subject: Re: Standardized gestures
>
> I'm not convinced you need any additional code here.
>
> Touch events are already fired by the web view containers. You could build
> up gesture detection in JavaScript by listening to these events.
>
> There are libraries out there that do this for you already:
>
>  - http://eightmedia.github.io/hammer.js/
>  - http://quojs.tapquo.com/
>  - https://github.com/plainview/Jester
>  - jquery ui plugin: http://touchpunch.furf.com/
>  - jquery plugin: http://labs.rampinteractive.co.uk/touchSwipe/demos/
>  - moar jquery: https://github.com/HotStudio/touchy
>
> On 4/17/13 9:42 AM, "jbo...@openmv.com" <jbo...@openmv.com> wrote:
>
> >I'm experimenting with Cordova on Android, iOS and Windows 8.
> >
> >Has there been a discussion around trying to implement to set of
> >'standard' gesture recognizers:
> >http://msdn.microsoft.com/library/windows/apps/BR241937
> >http://developer.apple.com/library/ios/#documentation/EventHandling/Con
> >cep
> >tual/EventHandlingiPhoneOS/GestureRecognizer_basics/GestureRecognizer_b
> >asi
> >cs.html
> >http://developer.android.com/reference/android/view/GestureDetector.htm
> >l
> >
> >The idea would be that the native side executes JavaScript like:
> >javascript:cordova.fireEvent('tap', {node:
> >document.elementFromPoint(400, 300), x: 400, y:300 });
> >javascript:cordova.fireEvent('slide', {node:
> >document.elementFromPoint(400, 300), x: 400, y:300});
> >
> >This function could use document.createEvent to initiate events on the
> >DOM node:
> >https://developer.mozilla.org/en-US/docs/DOM/document.createEvent
> >
> >The purpose of this would be to have a consistent set of gesture
> >recognition across different devices instead of having javascript code
> >in the 'WebView' trying to do gesture detection.
> >
> >Thoughts?
> >
>
>
>
>

Reply via email to