mudcube / Event.js

:hand: Multi-touch, gestures, and other events—click, dblclick, dbltap, tap, longpress, drag, swipe, pinch, rotate, shake. For pointer events, each listener can handle anywhere from 1 to 12 fingers at a time, or more, depending on the device. Includes MetaKey tracking (CMD, CTRL) to support native key-commands in various platforms.
MIT License
368 stars 68 forks source link

Can't cancel event bubbling #18

Closed stodge closed 8 years ago

stodge commented 8 years ago

I'm using eventjs to handle desktop and mobile events in a dynamic SVG document. I add event listeners to SVG elements:

    eventjs.add(this.rectNode, "click", function(event, self) {
         ...
         eventjs.cancel(event);
    }

I call eventjs.cancel(event) inside the event handler but it doesn't seem to prevent event bubbling. I have another event handler attached to a different SVG element that is used to pan the map and this handler is fired after the above handler is invoked. Is there something I'm doing wrong?

Thanks

stodge commented 8 years ago

I always find a solution after I post. I moved the event handler to the parent group and changed it from "click" to "mousedown" and it works now. Thanks