stephband / jquery.event.swipe

jQuery custom events swipeleft, swiperight, swipeup and swipedown
stephband.info/jquery.event.swipe
446 stars 180 forks source link

Event not triggered if bound in delegation mode #27

Closed Habared closed 9 years ago

Habared commented 9 years ago

Hi! Suppose we have some div boxes having class 'elem' whithin a container '#box'

this works:

$(".elem").on("swipeleft", function() {console.log("swipe");});

this doesn't work:

$("#box").on("swipeleft", ".elem", function() {console.log("swipe");});

Is there a reason I can't delegate swipe events? Am I missing something? Thank you.

stephband commented 9 years ago

The reason is that in this case unfortunately delegation would be bad for performance. Swipe events are a thin wrapper around move events (https://github.com/stephband/jquery.event.move). Use those if you need delegation.