yko
yko

Reputation: 2710

KineticJS: Disable dragging

I need to find out a way to disable dragging shapes in KineticJS

For example, I have a Circle with the draggable option enabled.

I want to disable dragging this circle if the shiftKey is pressed down and I would like to handle this case in a different way.

Here's an example of what I would like to do: http://jsfiddle.net/nL3kb/

Is it possible somehow?

Upvotes: 0

Views: 1880

Answers (1)

Eric Rowell
Eric Rowell

Reputation: 5219

You have several options. One thing you could do is make a group draggable and add the circle to the group. On mousedown, if shift was pressed, you can cancel the event propagation such that the group drag and drop functionality is canceled.

http://jsfiddle.net/SyMRJ/

You could also add logic that toggles off drag and drop using draggable(false) whenever the shift key is pressed down

Cheers!

Upvotes: 3

Related Questions