This is a read-only archive of the Framer Community on Facebook.

What is Framer? Join the Community
Return to index
Taylor Palmer
Posted Oct 05 - Read on Facebook

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.


Jonas Treub

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.

Taylor Palmer

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?

Jonas Treub

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.

Jonas Treub

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.

Read the entire post on Facebook