hypnomaki
hypnomaki

Reputation: 662

KonvaJS / Dynamically enable/disable interaction with layer

Is there an easy way in konvajs to disable the interaction/events (drag&drop/pointermove/click) for a layer and its children?

I have a setup containing multiple layers and interaction should only be possible with one layer at a time because elements from different layers are overlapping, which makes it hard for the user to click/drag the right element.

Worst would be to unregister/register every handler or intercepting all handlers, only executing the body based on the global state. As konvajs layers are individual canvas elements, I hope that there is a better way to do so (either in konvajs directly or manually on the canvas)

Upvotes: 0

Views: 723

Answers (1)

lavrton
lavrton

Reputation: 20308

Just set layer.listening(false). It should disable all events from layer and its children.

Upvotes: 1

Related Questions