craft.js icon indicating copy to clipboard operation
craft.js copied to clipboard

listen add new element event

Open hungchip opened this issue 2 years ago • 3 comments

How I can listen add new element event? I'm building a feature which is trigger a modal after I drag to add a new element How to control that event?

hungchip avatar Nov 16 '22 04:11 hungchip

I also need this kind of feature. Something like onElementAdded callback, I have tried onBeforeMoveEnd() but it looks like only worked when dragging elements that have been already added to the Frame.

riandy-dimas avatar Nov 16 '22 06:11 riandy-dimas

You can add a callback to connectors.create:

connectors.create(ref, node, { onCreate: (nodeTree) => {
  // nodeTree has been created
}});

ankri avatar Nov 16 '22 08:11 ankri

You can add a callback to connectors.create:

connectors.create(ref, node, { onCreate: (nodeTree) => {
  // nodeTree has been created
}});

thank you @ankri! this is what I was looking for 🙌

riandy-dimas avatar Nov 21 '22 03:11 riandy-dimas