googlearchive / polymer-gestures

84 stars 27 forks source link

Only emit gestures that are being listened for #36

Closed dfreedm closed 10 years ago

dfreedm commented 10 years ago

This change calculates what gestures are being listening for in the event path, and saves that list per pointer.

dfreedm commented 10 years ago

@sorvell PTAL

dfreedm commented 10 years ago

Here's an illustration for the behavior change:

<div id="a" on-tap="{{tap}}">
  <div id="b" on-track="{{track}}"></div>
  <div id="c" on-hold="{{hold}}"></div>
</div>
<div id="d" on-hold="{{hold}}"></div>

Before #36, a "tap" on #d would emit a tap gesture, even though no ancestor of #d was listening for it. After #36, the list of gestures to emit calculates what gestures are being listened for in the ancestors of node that received the "down".

In this example, any interaction with #c will only make "hold" and "tap" gestures.

Important note: even with #36, a tap on #c will dispatch the tap to #c and #b, even though the only listener for tap is #a

sorvell commented 10 years ago

LGTM