grapesjs icon indicating copy to clipboard operation
grapesjs copied to clipboard

Component Drag Event

Open yashvirsoftobiz opened this issue 8 years ago • 3 comments

I want to know how can I get that component from which element is dragged and drop to the other component. I need to add a class if component become empty if element is dragged and droped to the outside element. I can get the component which dragged and in which it droped but not from where it dragged. Any Help would be appreciated.

dragevent

yashvirsoftobiz avatar Sep 07 '18 12:09 yashvirsoftobiz

In your case, I think it would be better listen to inner components changes (eg. what if I delete all children components?), but currently, there is no such an event, so I'll try to add it for the next release. It should be something like this

editor.on('component:update:components', component => {
	// just modify the view element
	const el = component.getEl();
	const hasChildren = component.components().length;
	el.classList[hasChildren ? 'remove' : 'add']('component--is-empty');
})

artf avatar Sep 10 '18 22:09 artf

@YashPrince how did you get the id of the dragged component and where it was dropped

sakshigarg9 avatar Mar 25 '19 11:03 sakshigarg9

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

lock[bot] avatar Mar 27 '20 08:03 lock[bot]