react-draggable
react-draggable copied to clipboard
Possibility of trigger eventCallback 'onStart' or setState 'dragging' of Draggable JSX-element?
The situation I want to generate a new component (a new card) over some drag-and-drop-function. The plan: If the user start to drag from a button at the sidebar, a new draggable component should appear at his cursor. If he drop this component at a drop-zone, the component should be stay at that point. At other zones the component disappear.
And before you ask: To use the cursor-css-styles cannot work for me, they block all other mouse-events. They are important to adjust the new card.
The plan
The dragging-action is already in progress when the Draggable-component is mounted. She cannot trigger the onStart={} event by her own.
Because of this problem I search for a way to trigger the synthetic event onStart={} manually. What a real challenge is there is no way to get the <Draggable> JSX-element from the DOM. At least I didn't find any. Another way would be to modify the dragging-state from the Draggable component:
dragged:true
dragging:false
isElementSVG:false
prevPropsPosition:{x: 0, y: 0}
slackX:0
slackY:0
x:0
y:0
To add the class react-draggable-dragging did not work, i tried it already.
The question Is there a way to set the dragging-state manually? Or is there a way I didn't see to bind the element at the cursor, directly after mounting?