googlearchive / polymer-gestures

84 stars 28 forks source link

documentation: PolymerGestures.addEventListener(node, eventname, handler, capture); #54

Closed forresto closed 10 years ago

forresto commented 10 years ago

I was relying on polymer-gestures to make gesture events on various svg children of my custom element. Did something change there?

Edit: It doesn't work on the child elements on mobile either.


Edit: It was just an issue of the api changing from

node.addEventListener(eventname, handler, capture);

to

PolymerGestures.addEventListener(node, eventname, handler, capture);

forresto commented 10 years ago

Tried to make a reduced case with your example, changing to Polymer 0.4.0. Seems up and down are the only events that fire within the custom element: http://jsbin.com/tobon/1/edit

forresto commented 10 years ago

Hmm seems the same without the Polymer element: http://jsbin.com/bonige/1/edit?html,js,output

sbmaxx commented 10 years ago

I have working example here https://rozhdestvenskiy.ru/dev/gestures/polymer-gestures/samples/image/index.html

It uses my fork with all my PR's. I think your problem can be fixed with this one — https://github.com/Polymer/polymer-gestures/pull/48

forresto commented 10 years ago

@sbmaxx Thanks for taking a look. Seems the same with yours, unless I'm missing something: http://jsbin.com/cavuh/1/edit

sbmaxx commented 10 years ago

You should use PolymerGestures.addEventListener(capture, en, function(inEvent) {}); instead of capture.addEventListener. https://github.com/Polymer/polymer-gestures/blob/master/src/dispatcher.js#L401-L406

Demo — http://jsbin.com/votobeyonimu/1/

cc @forresto

forresto commented 10 years ago

Thanks for the tip. It actually works with the distributed 0.4.0 now: http://jsbin.com/meguma/1/edit

sbmaxx commented 10 years ago

It actually works with the distributed 0.4.0

try it on mobile ;) i made this fix while developing for iphone/ipad