konvajs / konva

Konva.js is an HTML5 Canvas JavaScript framework that extends the 2d context by enabling canvas interactivity for desktop and mobile applications.
http://konvajs.org/
Other
11.59k stars 926 forks source link

click, dblclick event not working for dragable layers #131

Closed MrEd69 closed 8 years ago

MrEd69 commented 8 years ago

I tried to migrate from KineticJS to KonvaJS, and found out, that draggable layers will not get the click or dblclick event. I think (cannot confirm now), that tap and dbltap would also not work.

lavrton commented 8 years ago

Can you provide example?

MrEd69 commented 8 years ago

Sorry, I tried to reproduce, but now at work with a different PC/mouse everything works. False alarm.

ivokund commented 7 years ago

I'm having the same issue.

                const object = new Konva.Circle({
                    100,
                    100,
                    radius: 5,
                    fill: '#fafafa',
                    stroke: 'black',
                    strokeWidth: 1,
                    draggable: true,
                });

                object.on('click', function() {
                    console.log('click');
                });

                map.itemLayer.add(object);

No output from the console. After changing draggable to false, I get output. Same with dblclick event. Mouseover and other events are working.

lavrton commented 7 years ago

@ivokund try to set dragDistance to some value (e.g. 5). I guess on your case click doesn't work because it triggers drag&drop (mousedown position != mouseup position). http://konvajs.github.io/api/Konva.Shape.html#dragDistance

ivokund commented 7 years ago

Yes, this helped, thanks!