Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Event delegation and how to stopPropagation preventDefaults
Hammer supports event delegation. It makes use of the createEvent method in JS, to create DOM events. When you take a look at the event object of a gesture event, you will see some methods, which might be confusing.
Stops bubbling the gesture event to its parents. So you can create nested events.
Prevents the browser from doing it's native gesture implementation. It doesn't make any sense, only for the drag events, since most browsers support dragstart-drag-dragend. It is in Hammer, because
document.createEvent adds these, and Hammer uses this for creating DOM events.
Stops the source event
ev.gesture.srcEvent from bubbling. The source event could be touchstart, touchmove, mousemove etc.
Prevents the source event
ev.gesture.srcEvent from doing it's native behavior.when you use this, you can make the element blocking, because touchstart-touchmove let the browser scroll when you dont prevent the default action. This could be called when you are using the drag and transform events, but hammer does this for you in most cases.
Stops Hammer from detecting any further gestures, in the current detection session. Might be usefull to call after you did a succesfull swipe.