Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic drag and drop (Read 1525 times)
Trupti
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 2
Joined: Feb 18th, 2019
drag and drop
Mar 1st, 2019 at 5:01am
Print Post  
Is there any way to find out if the dragged node is dropped on upper part or lower part of a node? See the attachment.

Thanks in advance..Smiley
  

drg.png ( 9 KB | 129 Downloads )
drg.png
Back to top
 
IP Logged
 
Lyubo
God Member
*****
Offline


MindFusion team

Posts: 511
Joined: Jun 17th, 2010
Re: drag and drop
Reply #1 - Mar 1st, 2019 at 9:59am
Print Post  
Hi,

You can hit-test for the nodes under the cursor by using diagram.getNodesAt method and than check where on the hit node the point under the cursor lies. You can try that from a nodeModifed handler for example:

Code (Javascript)
Select All
var Events = MindFusion.Diagramming.Events;

// ...

diagram.addEventListener(Events.nodeModified, function(sender, args) {
    if (args.getAdjustmentHandle() == 8) { // Move action

        var draggedNode = args.getNode(),
              location = args.getMousePosition(),
              hitNodes = diagram.getNodesAt(location);

        if (hitNodes.length > 1) {
            for (var i = 0; i < hitNodes.length; i++) {
                if (hitNodes[i] == draggedNode)
                    continue;

                var bounds = hitNodes[i].getBounds();

                if (location.y <= (bounds.y + bounds.height / 2))
                    console.log('top half');
                else
                    console.log('bottom half');
            }
        }
    }
}); 



Regards,
Lyubo
  
Back to top
 
IP Logged
 
Trupti
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 2
Joined: Feb 18th, 2019
Re: drag and drop
Reply #2 - Mar 1st, 2019 at 12:23pm
Print Post  
Thank You for the Response!! Smiley
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint