Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

234
Views
Gojs React+HTML drag ,disbale drop location to already existing nodes
div.addEventListener("drop", event => {
        // prevent default action
        // (open as link for some elements in some browsers)
        event.preventDefault();

        // Dragging onto a Diagram
        if (div === myDiagram.div) {
          var can = event.target;
          var pixelratio = myDiagram.computePixelRatio();

          // if the target is not the canvas, we may have trouble, so just quit:
          if (!(can instanceof HTMLCanvasElement)) return;

          var bbox = can.getBoundingClientRect();
          var bbw = bbox.width;
          if (bbw === 0) bbw = 0.001;
          var bbh = bbox.height;
          if (bbh === 0) bbh = 0.001;
          var mx = event.clientX - bbox.left * ((can.width / pixelratio) / bbw) - dragged.offsetX;
          var my = event.clientY - bbox.top * ((can.height / pixelratio) / bbh) - dragged.offsetY;
          var point = myDiagram.transformViewToDoc(new go.Point(mx, my));
          myDiagram.startTransaction('new node');
          myDiagram.model.addNodeData({
            location: point,
            text: event.dataTransfer.getData('text'),
            color: "lightyellow"
          });
          myDiagram.commitTransaction('new node');

          // remove dragged element from its old location
          if (remove.checked) dragged.parentNode.removeChild(dragged);
        }

        // If we were using drag data, we could get it here, ie:
        // var data = event.dataTransfer.getData('text');
      }, false);

Am using HTML drag and drop , and dropping to Canvas (GOJS) Area. So far working fine , am able to drag elements from one component( giving draggable="true") to the elements and dropping to another component using onDrop function and onDragOver function , and once dropped , am constructing new nodes

Everything working as expected , i have 2 queries basically

  1. I dont want to drag elements to overlap already existing nodes. Meaning whenever i am dragging and entering to drop area i can see green + sign and now I am able to drop to the already existing nodes (imagine already 3 nodes are there for some diagram) , so that it will overlap , some how i NEED to restrict and show X sign when it overlap already existing nodes and should NOT allow to drop on other nodes

  2. When i dragged and dropped element , is there any way i can highlight node , giving impression its the newly added node.

I am taking reference from this url https://github.com/NorthwoodsSoftware/GoJS/blob/master/samples/htmlDragDrop.html

Can anyone help me with it

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!