You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Dear @artf I am implementing custom drag-and-drop (DND) logic using drag mode: translate in GrapesJS. The issue arises when I move a component into a specific target component that meets certain conditions. To handle this, I am using the GrapesJS move method:
// Move the component to the target component.move(target.element, { at: children.length })
This moves the component’s HTML to the new target destination, detaching it from its previous parent. As a result, dragging the original parent no longer affects the moved component.
Problem Statement:
After moving the component to a new destination, how can I accurately retrieve its updated X, Y coordinates in relation to the new parent?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Dear @artf I am implementing custom drag-and-drop (DND) logic using drag mode: translate in GrapesJS. The issue arises when I move a component into a specific target component that meets certain conditions. To handle this, I am using the GrapesJS move method:
// Move the component to the target component.move(target.element, { at: children.length })
This moves the component’s HTML to the new target destination, detaching it from its previous parent. As a result, dragging the original parent no longer affects the moved component.
Problem Statement:
After moving the component to a new destination, how can I accurately retrieve its updated X, Y coordinates in relation to the new parent?
`
const calculateExactDropPosition = (
component,
targetElement,
event,
editorInstance
) => {
return {
offsetX: "",
offsetY: "",
}
}
component.setStyle({
width: originalWidth,
transform:
translateX(${offsetX}px) translateY(${offsetY}px)
,})
`
These computations are being performed inside the
component:drag:end event.
Beta Was this translation helpful? Give feedback.
All reactions