Hi, I'm working on a prototype that creates a new layer everytime you drag an image from a panel. Can anyone take a look through my code to see what I'm doing wrong?
I'm using the function CreateShape() to create a new layer, but after the second layer it breaks.
Each time on drag start you are adding the same listeners. If you print something in drag end, you'll notice the problem after a few drag interactions.
Thanks Jonas Treub. Even though I've added "off" after DragEnd, the problem continues. Do I need to add and remove the event listeners each time?
You’ll need to give the exact same function as a reference to make the off action work. Because the function is written in-line that’s not possible right now.
Personally I (almost) never write code to remove events. I keep the events firing all the time and inside the handler I decide whether to do something or not.