though still working on wraping up the tests/doh and docs, would like
to get it out for more thoughts.
- Tracking ticket - http://bugs.dojotoolkit.org/ticket/13828
- Refined code for browsing - https://github.com/evanhw/touch/tree/master/dojo
- Patch - http://bugs.dojotoolkit.org/attachment/ticket/13828/%2313828.patch
The above initially finished version mainly includes following changes:
1.Registry is removed, and major content of dojo.gesture is moved to
dojo/gesture/Base as a parental class.
2.Used on.emit() to fire and bubble gesture events
3.Added dojo.touch.cancel handle so that we a gesture can be cancelled.
4.Changed swipe to keep firing events during touchmove, the previous
version is actually a flicker gesture(though we may add it back later)
Also due to the fact that it's still subject to possible changes, I
intend to move it to dojox marked as experimental so that we have a
safer way to try it out and finalize the design and API after 1.7
Any comments are appreciated!
--------------------------------------------------------------------------------------------------------------------------------
Also moving related ticket discusson here:
#13828: [CLA][PATCH] Refine dojo/gesture and dojo/gesture/*
Comment (by Evan):
Thanks, Bill,
Replying to [comment:4 bill]:
I checked it over a bit. Questions:
- Not sure what "defaultEvent" or "subEvents" attributes in
subclasses of gesture/Base is for? Maybe I'm missing something, but
they don't seem necessary. Likewise with init(), _events and _remove().
I'm just not seeing why you need an infrastructure more complicated than
dojo/touch uses.
"defaultEvent" and "subEvents" mainly to accommodate with the Object- Not sure what "defaultEvent" or "subEvents" attributes in
subclasses of gesture/Base is for? Maybe I'm missing something, but
they don't seem necessary. Likewise with init(), _events and _remove().
I'm just not seeing why you need an infrastructure more complicated than
dojo/touch uses.
event, e.g. since we have the following usage:
- on(node, dojo.gesture.tap, func);
- on(node, dojo.gesture.tap.hold, func);
- on(node, dojo.gesture.tap.doubletap, func);
doesn't that already indicate a main-sub relationship e.g tap.hold.
Also we can't provide
- on(node, dojo.gesture.taphold, func)
since that violates module return way.
Maybe we can have a simper list, but still in the form as e.g. ["tap",
"tap.hold", "tap.doubletap"] to be consistent with the Object event usage?
The logic is a bit complex than touch because unlike dojo.touch which is
simply listening to native events, besides gesture event, dojo.gesture
also needs to listen, process and dispatch
"press"|"move"|"release"(including remove them - user won't explicitly do
that).
- You are firing synthetic DOM events as a side effect when on() is
called for a node. Is the idea that an app would call {{{on(node,
gesture.swipe, function(){/*empty function*/})}}} and then instead setup
handlers on <body> via {{{on(dojo.body(), "swipe.end", ...)}}}? I don't
really see the value here.
No, that's a not provided usage. "swipe.end" is simply the event.type usercalled for a node. Is the idea that an app would call {{{on(node,
gesture.swipe, function(){/*empty function*/})}}} and then instead setup
handlers on <body> via {{{on(dojo.body(), "swipe.end", ...)}}}? I don't
really see the value here.
got from callback in
- on(node, gesture.swipe, function(event){})
- I expected the swipe module to return {move: ..., end: ...} hash
rather than being used as swipe (which is the move gesture) and swipe.end.
Although either way works.
Hmm, was just thinng dojo.gesture.swipe is more clean to use.rather than being used as swipe (which is the move gesture) and swipe.end.
Although either way works.
- I thought a swipe implied a short, fast gesture but it looks like
the swipe code will fire on any touch move, even a long slow one?
Yep, based on my new understanding, swipe is just what you do when swiping
the screen of iPad or iPhone, no matter fast or slow, the viewport will be
slides.
A faster one but only fired when touchend is a flicker.the swipe code will fire on any touch move, even a long slow one?
Yep, based on my new understanding, swipe is just what you do when swiping
the screen of iPad or iPhone, no matter fast or slow, the viewport will be
slides.
- the {{{lang.getObject("gesture", true, dojo);}}} in gesture/Base seems unnecessary
- in tap.js there's a clearTimeout() inside a setTimeout() callback that is unnecessary.
Gonna have a check, thx!- in tap.js there's a clearTimeout() inside a setTimeout() callback that is unnecessary.
- in the line {{{this.fire(e.target, {type: "tap.doubletap"});}}}, it
seems unusual to have an event type containing a dot; it's inconsistent
with the browser native event doubleclick (which is called "doubleclick",
not "click.doubleclick")
Yep, I have the similar concern, but here just want to be consistentseems unusual to have an event type containing a dot; it's inconsistent
with the browser native event doubleclick (which is called "doubleclick",
not "click.doubleclick")
with Object events usage as:
- on(node, dojo.gesture.tap, func);
- on(node, dojo.gesture.tap.hold, func);
- on(node, dojo.gesture.tap.doubletap, func);
Of course we can directly fire "tap", "taphold", "doubletap" or "swipeend"
etc. if we don't worry about that.