Treeview and Diagram Drag and drop

Good day,


I am having an issue with regards to the use of the Treeview component and the diagram drag and drop.

On Drag enter from the treeview, i create a node with custom HTML then add it to the diagram. The node gets created but not under the cursor as the user would expect it to happen. Just like in the link below.

https://stackblitz.com/run?file=src%2Fapp.component.html,src%2Fapp.component.ts

Attached is an image to illustrate 

Image_2881_1720508985877

What are the properties that are associated with control the positioning during dragenter


3 Replies 1 reply marked as answer

VG Vivisa Ganesan Syncfusion Team July 10, 2024 01:25 PM UTC

Hi,

We have modified the sample to meet your requirements. In this version, we have bound the mouse cursor position to the offsetX and offsetY properties of the node in the dragEnter event. The mouse position is accessed using the Angular mousemove event. Refer to the sample and code snippet below:

 

  public dragEnter(args: any) {

    let lable = '';

    if (args.dragData) {

      lable = args.dragData.text;

    }

    let node = {

      id: 'node' + this.index,

      data: { Name: lable, Id: 'node' + this.index },

      annotations: [{ content: lable }],

      offsetX: mouseX,

      offsetY: mouseY,

    };

    args.dragItem = node;

  }


Sample:

6zk3au (forked) - StackBlitz


Regards,

Vivisa


Marked as answer

NN nqaba nleya July 10, 2024 01:37 PM UTC

This works. Thank you!



VG Vivisa Ganesan Syncfusion Team July 11, 2024 04:18 AM UTC

Hi,

You're welcome! Please let us know if you have any further queries on this. We will be happy to assist.

 

Regards,

Vivisa


Loader.
Up arrow icon