@joint/core 4.0.1 → 4.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- /*! JointJS v4.0.1 (2024-02-02) - JavaScript diagramming library
1
+ /*! JointJS v4.0.3 (2024-05-14) - JavaScript diagramming library
2
2
 
3
3
 
4
4
  This Source Code Form is subject to the terms of the Mozilla Public
@@ -13759,6 +13759,10 @@ var joint = (function (exports) {
13759
13759
  var ry2 = ry * ry;
13760
13760
 
13761
13761
  var k = ((large_arc_flag == sweep_flag) ? -1 : 1) * sqrt(abs(((rx2 * ry2) - (rx2 * y * y) - (ry2 * x * x)) / ((rx2 * y * y) + (ry2 * x * x))));
13762
+ if (!Number.isFinite(k)) {
13763
+ // Arc is a single point
13764
+ return [x1, y1, x2, y2, x2, y2];
13765
+ }
13762
13766
 
13763
13767
  var cx = ((k * rx * y) / ry) + ((x1 + x2) / 2);
13764
13768
  var cy = ((k * -ry * x) / rx) + ((y1 + y2) / 2);
@@ -17519,12 +17523,16 @@ var joint = (function (exports) {
17519
17523
  if (text === undefined) { text = attrs.text; }
17520
17524
  if (text !== undefined) {
17521
17525
  var breakTextFn = value.breakText || breakText;
17526
+ var computedStyles = getComputedStyle(node);
17527
+
17522
17528
  wrappedText = breakTextFn('' + text, size, {
17523
- 'font-weight': attrs['font-weight'],
17524
- 'font-size': attrs['font-size'],
17525
- 'font-family': attrs['font-family'],
17529
+ 'font-weight': computedStyles.fontWeight,
17530
+ 'font-family': computedStyles.fontFamily,
17531
+ 'text-transform': computedStyles.textTransform,
17532
+ 'font-size': computedStyles.fontSize,
17533
+ 'letter-spacing': computedStyles.letterSpacing,
17534
+ // The `line-height` attribute in SVG is JoinJS specific.
17526
17535
  'lineHeight': attrs['line-height'],
17527
- 'letter-spacing': attrs['letter-spacing']
17528
17536
  }, {
17529
17537
  // Provide an existing SVG Document here
17530
17538
  // instead of creating a temporary one over again.
@@ -20333,6 +20341,13 @@ var joint = (function (exports) {
20333
20341
  'port-group': port.group
20334
20342
  });
20335
20343
 
20344
+ // If the port ID is a number, we need to add
20345
+ // extra information to the port element to distinguish
20346
+ // between ports with the same ID but different types.
20347
+ if (isNumber(port.id)) {
20348
+ portElement.attr('port-id-type', 'number');
20349
+ }
20350
+
20336
20351
  var labelMarkupDef = this._getPortLabelMarkup(port.label);
20337
20352
  if (Array.isArray(labelMarkupDef)) {
20338
20353
  // JSON Markup
@@ -23855,23 +23870,25 @@ var joint = (function (exports) {
23855
23870
  return this;
23856
23871
  },
23857
23872
 
23858
- findAttribute: function(attributeName, node) {
23859
-
23873
+ findAttributeNode: function(attributeName, node) {
23860
23874
  var currentNode = node;
23861
-
23862
23875
  while (currentNode && currentNode.nodeType === 1) {
23863
- var attributeValue = currentNode.getAttribute(attributeName);
23864
23876
  // attribute found
23865
- if (attributeValue) { return attributeValue; }
23877
+ // (empty value does not count as attribute found)
23878
+ if (currentNode.getAttribute(attributeName)) { return currentNode; }
23866
23879
  // do not climb up the DOM
23867
23880
  if (currentNode === this.el) { return null; }
23868
23881
  // try parent node
23869
23882
  currentNode = currentNode.parentNode;
23870
23883
  }
23871
-
23872
23884
  return null;
23873
23885
  },
23874
23886
 
23887
+ findAttribute: function(attributeName, node) {
23888
+ var matchedNode = this.findAttributeNode(attributeName, node);
23889
+ return matchedNode && matchedNode.getAttribute(attributeName);
23890
+ },
23891
+
23875
23892
  // Override the mvc ViewBase `_ensureElement()` method in order to create an
23876
23893
  // svg element (e.g., `<g>`) node that wraps all the nodes of the Cell view.
23877
23894
  // Expose class name setter as a separate method.
@@ -27319,8 +27336,14 @@ var joint = (function (exports) {
27319
27336
  var ty = target.y0;
27320
27337
 
27321
27338
  if (tx === ax && ty < sy0) { return Directions$2.BOTTOM; }
27322
- if (tx < ax && ty < smy0) { return Directions$2.RIGHT; }
27323
- if (tx > ax && ty < smy0) { return Directions$2.LEFT; }
27339
+ if (tx < ax && ty < smy0) {
27340
+ if (nextInLine.point.x === ax) { return Directions$2.BOTTOM; }
27341
+ return Directions$2.RIGHT;
27342
+ }
27343
+ if (tx > ax && ty < smy0) {
27344
+ if (nextInLine.point.x === ax) { return Directions$2.BOTTOM; }
27345
+ return Directions$2.LEFT;
27346
+ }
27324
27347
  if (tx < smx0 && ty >= sy0) { return Directions$2.TOP; }
27325
27348
  if (tx > smx1 && ty >= sy0) { return Directions$2.TOP; }
27326
27349
  if (tx >= smx0 && tx <= ax && ty > sy1) {
@@ -27359,8 +27382,14 @@ var joint = (function (exports) {
27359
27382
  var ty = target.y0;
27360
27383
 
27361
27384
  if (tx === ax && ty > sy1) { return Directions$2.TOP; }
27362
- if (tx < ax && ty > smy1) { return Directions$2.RIGHT; }
27363
- if (tx > ax && ty > smy1) { return Directions$2.LEFT; }
27385
+ if (tx < ax && ty > smy1) {
27386
+ if (nextInLine.point.x === ax) { return Directions$2.TOP; }
27387
+ return Directions$2.RIGHT;
27388
+ }
27389
+ if (tx > ax && ty > smy1) {
27390
+ if (nextInLine.point.x === ax) { return Directions$2.TOP; }
27391
+ return Directions$2.LEFT;
27392
+ }
27364
27393
  if (tx < smx0 && ty <= sy1) { return Directions$2.BOTTOM; }
27365
27394
  if (tx > smx1 && ty <= sy1) { return Directions$2.BOTTOM; }
27366
27395
  if (tx >= smx0 && tx <= ax && ty < sy0) {
@@ -27571,11 +27600,12 @@ var joint = (function (exports) {
27571
27600
  return outsidePoint;
27572
27601
  }
27573
27602
 
27574
- function routeBetweenPoints(source, target) {
27603
+ function routeBetweenPoints(source, target, opt) {
27604
+ if ( opt === void 0 ) opt = {};
27605
+
27575
27606
  var sourcePoint = source.point;
27576
27607
  var sx0 = source.x0;
27577
27608
  var sy0 = source.y0;
27578
- var sourceView = source.view;
27579
27609
  var sourceWidth = source.width;
27580
27610
  var sourceHeight = source.height;
27581
27611
  var sourceMargin = source.margin;
@@ -27585,14 +27615,13 @@ var joint = (function (exports) {
27585
27615
  var targetWidth = target.width;
27586
27616
  var targetHeight = target.height;
27587
27617
  var targetMargin = target.margin;
27618
+ var targetInSourceBBox = opt.targetInSourceBBox; if ( targetInSourceBBox === void 0 ) targetInSourceBBox = false;
27588
27619
 
27589
27620
  var tx1 = tx0 + targetWidth;
27590
27621
  var ty1 = ty0 + targetHeight;
27591
27622
  var sx1 = sx0 + sourceWidth;
27592
27623
  var sy1 = sy0 + sourceHeight;
27593
27624
 
27594
- var isSourceEl = sourceView && sourceView.model.isElement();
27595
-
27596
27625
  // Key coordinates including the margin
27597
27626
  var smx0 = sx0 - sourceMargin;
27598
27627
  var smx1 = sx1 + sourceMargin;
@@ -27622,10 +27651,15 @@ var joint = (function (exports) {
27622
27651
  var middleOfVerticalSides = (scx < tcx ? (sx1 + tx0) : (tx1 + sx0)) / 2;
27623
27652
  var middleOfHorizontalSides = (scy < tcy ? (sy1 + ty0) : (ty1 + sy0)) / 2;
27624
27653
 
27654
+ var sourceBBox = new Rect(sx0, sy0, sourceWidth, sourceHeight);
27655
+ var targetBBox = new Rect(tx0, ty0, targetWidth, targetHeight);
27656
+ var inflatedSourceBBox = sourceBBox.clone().inflate(sourceMargin);
27657
+ var inflatedTargetBBox = targetBBox.clone().inflate(targetMargin);
27658
+
27625
27659
  if (sourceSide === 'left' && targetSide === 'right') {
27626
27660
  if (smx0 <= tmx1) {
27627
27661
  var y = middleOfHorizontalSides;
27628
- if (sx1 <= tx0) {
27662
+ if (sox <= tmx0) {
27629
27663
  if (ty1 >= smy0 && toy < soy) {
27630
27664
  y = Math.min(tmy0, smy0);
27631
27665
  } else if (ty0 <= smy1 && toy >= soy) {
@@ -27646,7 +27680,7 @@ var joint = (function (exports) {
27646
27680
  { x: x, y: toy }
27647
27681
  ];
27648
27682
  } else if (sourceSide === 'right' && targetSide === 'left') {
27649
- if (smx1 >= tmx0) {
27683
+ if (sox >= tmx0) {
27650
27684
  var y$1 = middleOfHorizontalSides;
27651
27685
  if (sox > tx1) {
27652
27686
  if (ty1 >= smy0 && toy < soy) {
@@ -27670,16 +27704,20 @@ var joint = (function (exports) {
27670
27704
  { x: x$1, y: toy }
27671
27705
  ];
27672
27706
  } else if (sourceSide === 'top' && targetSide === 'bottom') {
27707
+ var isPointInsideSource = intersection.rectWithRect(inflatedSourceBBox, targetBBox);
27708
+
27673
27709
  if (soy < toy) {
27674
27710
  var x$2 = middleOfVerticalSides;
27675
27711
  var y$2 = soy;
27676
27712
 
27677
- if (soy < ty0) {
27678
- if (tx1 >= smx0 && tox < sox) {
27679
- x$2 = Math.min(tmx0, smx0);
27680
- } else if (tx0 <= smx1 && tox >= sox) {
27681
- x$2 = Math.max(tmx1, smx1);
27682
- }
27713
+ if (isPointInsideSource) {
27714
+ y$2 = Math.min(y$2, tmy0);
27715
+ }
27716
+
27717
+ if (tx1 >= smx0 && tox < sox) {
27718
+ x$2 = Math.min(tmx0, smx0);
27719
+ } else if (tx0 <= smx1 && tox >= sox) {
27720
+ x$2 = Math.max(tmx1, smx1);
27683
27721
  }
27684
27722
 
27685
27723
  return [
@@ -27695,16 +27733,20 @@ var joint = (function (exports) {
27695
27733
  { x: tox, y: y$3 }
27696
27734
  ];
27697
27735
  } else if (sourceSide === 'bottom' && targetSide === 'top') {
27698
- if (soy - sourceMargin > toy) {
27736
+ var isPointInsideSource$1 = intersection.rectWithRect(inflatedSourceBBox, targetBBox);
27737
+
27738
+ if (soy > toy) {
27699
27739
  var x$3 = middleOfVerticalSides;
27700
27740
  var y$4 = soy;
27701
27741
 
27702
- if (soy > ty1) {
27703
- if (tx1 >= smx0 && tox < sox) {
27704
- x$3 = Math.min(tmx0, smx0);
27705
- } else if (tx0 <= smx1 && tox >= sox) {
27706
- x$3 = Math.max(tmx1, smx1);
27707
- }
27742
+ if (isPointInsideSource$1) {
27743
+ y$4 = Math.max(y$4, tmy1);
27744
+ }
27745
+
27746
+ if (tx1 >= smx0 && tox < sox) {
27747
+ x$3 = Math.min(tmx0, smx0);
27748
+ } else if (tx0 <= smx1 && tox >= sox) {
27749
+ x$3 = Math.max(tmx1, smx1);
27708
27750
  }
27709
27751
 
27710
27752
  return [
@@ -27720,28 +27762,31 @@ var joint = (function (exports) {
27720
27762
  { x: tox, y: y$5 }
27721
27763
  ];
27722
27764
  } else if (sourceSide === 'top' && targetSide === 'top') {
27765
+ var useUShapeConnection =
27766
+ targetInSourceBBox ||
27767
+ intersection.rectWithRect(inflatedSourceBBox, targetBBox) ||
27768
+ (soy <= ty0 && (inflatedSourceBBox.bottomRight().x <= tox || inflatedSourceBBox.bottomLeft().x >= tox)) ||
27769
+ (soy >= ty0 && (inflatedTargetBBox.bottomRight().x <= sox || inflatedTargetBBox.bottomLeft().x >= sox));
27770
+
27771
+ if (useUShapeConnection) {
27772
+ return [
27773
+ { x: sox, y: Math.min(soy, toy) },
27774
+ { x: tox, y: Math.min(soy, toy) }
27775
+ ];
27776
+ }
27777
+
27723
27778
  var x$4;
27724
27779
  var y1 = Math.min((sy1 + ty0) / 2, toy);
27725
27780
  var y2 = Math.min((sy0 + ty1) / 2, soy);
27726
27781
 
27727
27782
  if (toy < soy) {
27728
- if (sox >= tmx1 || sox <= tmx0) {
27729
- return [
27730
- { x: sox, y: Math.min(soy, toy) },
27731
- { x: tox, y: Math.min(soy, toy) }
27732
- ];
27733
- } else if (tox > sox) {
27783
+ if (tox > sox) {
27734
27784
  x$4 = Math.min(sox, tmx0);
27735
27785
  } else {
27736
27786
  x$4 = Math.max(sox, tmx1);
27737
27787
  }
27738
27788
  } else {
27739
- if (tox >= smx1 || tox <= smx0) {
27740
- return [
27741
- { x: sox, y: Math.min(soy, toy) },
27742
- { x: tox, y: Math.min(soy, toy) }
27743
- ];
27744
- } else if (tox >= sox) {
27789
+ if (tox >= sox) {
27745
27790
  x$4 = Math.max(tox, smx1);
27746
27791
  } else {
27747
27792
  x$4 = Math.min(tox, smx0);
@@ -27755,28 +27800,31 @@ var joint = (function (exports) {
27755
27800
  { x: tox, y: y1 }
27756
27801
  ];
27757
27802
  } else if (sourceSide === 'bottom' && targetSide === 'bottom') {
27803
+ var useUShapeConnection$1 =
27804
+ targetInSourceBBox ||
27805
+ intersection.rectWithRect(inflatedSourceBBox, targetBBox) ||
27806
+ (soy >= toy && (inflatedSourceBBox.topRight().x <= tox || inflatedSourceBBox.topLeft().x >= tox)) ||
27807
+ (soy <= toy && (inflatedTargetBBox.topRight().x <= sox || inflatedTargetBBox.topLeft().x >= sox));
27808
+
27809
+ if (useUShapeConnection$1) {
27810
+ return [
27811
+ { x: sox, y: Math.max(soy, toy) },
27812
+ { x: tox, y: Math.max(soy, toy) }
27813
+ ];
27814
+ }
27815
+
27758
27816
  var x$5;
27759
27817
  var y1$1 = Math.max((sy0 + ty1) / 2, toy);
27760
27818
  var y2$1 = Math.max((sy1 + ty0) / 2, soy);
27761
27819
 
27762
27820
  if (toy > soy) {
27763
- if (sox >= tmx1 || sox <= tmx0) {
27764
- return [
27765
- { x: sox, y: Math.max(soy, toy) },
27766
- { x: tox, y: Math.max(soy, toy) }
27767
- ];
27768
- } else if (tox > sox) {
27821
+ if (tox > sox) {
27769
27822
  x$5 = Math.min(sox, tmx0);
27770
27823
  } else {
27771
27824
  x$5 = Math.max(sox, tmx1);
27772
27825
  }
27773
27826
  } else {
27774
- if (tox >= smx1 || tox <= smx0) {
27775
- return [
27776
- { x: sox, y: Math.max(soy, toy) },
27777
- { x: tox, y: Math.max(soy, toy) }
27778
- ];
27779
- } else if (tox >= sox) {
27827
+ if (tox >= sox) {
27780
27828
  x$5 = Math.max(tox, smx1);
27781
27829
  } else {
27782
27830
  x$5 = Math.min(tox, smx0);
@@ -27790,6 +27838,19 @@ var joint = (function (exports) {
27790
27838
  { x: tox, y: y1$1 }
27791
27839
  ];
27792
27840
  } else if (sourceSide === 'left' && targetSide === 'left') {
27841
+ var useUShapeConnection$2 =
27842
+ targetInSourceBBox ||
27843
+ intersection.rectWithRect(inflatedSourceBBox, targetBBox) ||
27844
+ (sox <= tox && (inflatedSourceBBox.bottomRight().y <= toy || inflatedSourceBBox.topRight().y >= toy)) ||
27845
+ (sox >= tox && (inflatedTargetBBox.bottomRight().y <= soy || inflatedTargetBBox.topRight().y >= soy));
27846
+
27847
+ if (useUShapeConnection$2) {
27848
+ return [
27849
+ { x: Math.min(sox, tox), y: soy },
27850
+ { x: Math.min(sox, tox), y: toy }
27851
+ ];
27852
+ }
27853
+
27793
27854
  var y$6;
27794
27855
  var x1 = Math.min((sx1 + tx0) / 2, tox);
27795
27856
  var x2 = Math.min((sx0 + tx1) / 2, sox);
@@ -27815,11 +27876,24 @@ var joint = (function (exports) {
27815
27876
  { x: x1, y: toy }
27816
27877
  ];
27817
27878
  } else if (sourceSide === 'right' && targetSide === 'right') {
27879
+ var useUShapeConnection$3 =
27880
+ targetInSourceBBox ||
27881
+ intersection.rectWithRect(inflatedSourceBBox, targetBBox) ||
27882
+ (sox >= tox && (inflatedSourceBBox.bottomLeft().y <= toy || inflatedSourceBBox.topLeft().y >= toy)) ||
27883
+ (sox <= tox && (inflatedTargetBBox.bottomLeft().y <= soy || inflatedTargetBBox.topLeft().y >= soy));
27884
+
27885
+ if (useUShapeConnection$3) {
27886
+ return [
27887
+ { x: Math.max(sox, tox), y: soy },
27888
+ { x: Math.max(sox, tox), y: toy }
27889
+ ];
27890
+ }
27891
+
27818
27892
  var y$7;
27819
27893
  var x1$1 = Math.max((sx0 + tx1) / 2, tox);
27820
27894
  var x2$1 = Math.max((sx1 + tx0) / 2, sox);
27821
27895
 
27822
- if (tox < sox) {
27896
+ if (tox <= sox) {
27823
27897
  if (toy <= soy) {
27824
27898
  y$7 = Math.min(smy0, toy);
27825
27899
  } else {
@@ -27840,16 +27914,44 @@ var joint = (function (exports) {
27840
27914
  { x: x1$1, y: toy }
27841
27915
  ];
27842
27916
  } else if (sourceSide === 'top' && targetSide === 'right') {
27843
- if (soy > toy) {
27917
+ var isPointInsideSource$2 = inflatedSourceBBox.containsPoint(targetPoint);
27918
+
27919
+ // The target point is inside the source element
27920
+ if (isPointInsideSource$2) {
27921
+ if (sox <= tmx1) {
27922
+ var x$6 = Math.max(sox + sourceMargin, tox);
27923
+ var y$8 = Math.min(smy0, tmy0);
27924
+
27925
+ // Target anchor is on the right side of the source anchor
27926
+ return [
27927
+ { x: sox, y: y$8 },
27928
+ { x: x$6, y: y$8 },
27929
+ { x: x$6, y: toy }
27930
+ ];
27931
+ }
27932
+
27933
+ // Target anchor is on the left side of the source anchor
27934
+ // Subtract the `sourceMargin` since the source anchor is on the right side of the target anchor
27935
+ var anchorMiddleX = (sox - sourceMargin + tox) / 2;
27936
+
27937
+ return [
27938
+ { x: sox, y: soy },
27939
+ { x: anchorMiddleX, y: soy },
27940
+ { x: anchorMiddleX, y: toy }
27941
+ ];
27942
+ }
27943
+
27944
+ if (smy0 > toy) {
27844
27945
  if (sox < tox) {
27845
- var y$8 = middleOfHorizontalSides;
27946
+ var y$9 = tmy0;
27846
27947
 
27847
- if ((y$8 > tcy || !isSourceEl) && y$8 < tmy1 && sox < tx0) {
27848
- y$8 = tmy0;
27948
+ if (tmy1 <= smy0 && tmx1 >= sox) {
27949
+ y$9 = middleOfHorizontalSides;
27849
27950
  }
27951
+
27850
27952
  return [
27851
- { x: sox, y: y$8 },
27852
- { x: tox, y: y$8 },
27953
+ { x: sox, y: y$9 },
27954
+ { x: tox, y: y$9 },
27853
27955
  { x: tox, y: toy }
27854
27956
  ];
27855
27957
  }
@@ -27857,273 +27959,523 @@ var joint = (function (exports) {
27857
27959
  return [{ x: sox, y: toy }];
27858
27960
  }
27859
27961
 
27860
- var x$6 = Math.max(middleOfVerticalSides, tmx1);
27962
+ var x$7 = Math.max(middleOfVerticalSides, tmx1);
27861
27963
 
27862
- if (tox < sox && toy > sy0 && toy < sy1) {
27964
+ if (sox > tox && sy1 >= toy) {
27863
27965
  return [
27864
27966
  { x: sox, y: soy },
27865
- { x: x$6, y: soy },
27866
- { x: x$6, y: toy }
27967
+ { x: x$7, y: soy },
27968
+ { x: x$7, y: toy }
27867
27969
  ];
27868
27970
  }
27869
27971
 
27870
- if ((x$6 > smx0 && toy > sy0) || tx0 > sx1) {
27871
- var y$9 = Math.min(sy0 - sourceMargin, ty0 - targetMargin);
27872
- var x$7 = Math.max(sx1 + sourceMargin, tx1 + targetMargin);
27972
+ if (x$7 > smx0 && soy < ty1) {
27973
+ var y$10 = Math.min(smy0, tmy0);
27974
+ var x$8 = Math.max(smx1, tmx1);
27873
27975
  return [
27874
- { x: sox, y: y$9 },
27875
- { x: x$7, y: y$9 },
27876
- { x: x$7, y: toy }
27976
+ { x: sox, y: y$10 },
27977
+ { x: x$8, y: y$10 },
27978
+ { x: x$8, y: toy }
27877
27979
  ];
27878
27980
  }
27879
27981
 
27880
27982
  return [
27881
27983
  { x: sox, y: soy },
27882
- { x: Math.max(x$6, tox), y: soy },
27883
- { x: Math.max(x$6, tox), y: toy }
27984
+ { x: x$7, y: soy },
27985
+ { x: x$7, y: toy }
27884
27986
  ];
27885
27987
  } else if (sourceSide === 'top' && targetSide === 'left') {
27886
- if (soy > toy) {
27988
+ var isPointInsideSource$3 = inflatedSourceBBox.containsPoint(targetPoint);
27989
+
27990
+ // The target point is inside the source element
27991
+ if (isPointInsideSource$3) {
27992
+ if (sox >= tmx0) {
27993
+ var x$9 = Math.min(sox - sourceMargin, tox);
27994
+ var y$11 = Math.min(smy0, tmy0);
27995
+
27996
+ // Target anchor is on the left side of the source anchor
27997
+ return [
27998
+ { x: sox, y: y$11 },
27999
+ { x: x$9, y: y$11 },
28000
+ { x: x$9, y: toy }
28001
+ ];
28002
+ }
28003
+
28004
+ // Target anchor is on the right side of the source anchor
28005
+ // Add the `sourceMargin` since the source anchor is on the left side of the target anchor
28006
+ var anchorMiddleX$1 = (sox + sourceMargin + tox) / 2;
28007
+
28008
+ return [
28009
+ { x: sox, y: soy },
28010
+ { x: anchorMiddleX$1, y: soy },
28011
+ { x: anchorMiddleX$1, y: toy }
28012
+ ];
28013
+ }
28014
+
28015
+ if (smy0 > toy) {
27887
28016
  if (sox > tox) {
27888
- var y$10 = middleOfHorizontalSides;
28017
+ var y$12 = tmy0;
27889
28018
 
27890
- if ((y$10 > tcy || !isSourceEl) && y$10 < tmy1 && sox > tx1) {
27891
- y$10 = tmy0;
28019
+ if (tmy1 <= smy0 && tmx0 <= sox) {
28020
+ y$12 = middleOfHorizontalSides;
27892
28021
  }
28022
+
27893
28023
  return [
27894
- { x: sox, y: y$10 },
27895
- { x: tox, y: y$10 },
28024
+ { x: sox, y: y$12 },
28025
+ { x: tox, y: y$12 },
27896
28026
  { x: tox, y: toy }
27897
28027
  ];
27898
28028
  }
28029
+
27899
28030
  return [{ x: sox, y: toy }];
27900
28031
  }
27901
28032
 
27902
- var x$8 = Math.min(tmx0, middleOfVerticalSides);
28033
+ var x$10 = Math.min(tmx0, middleOfVerticalSides);
27903
28034
 
27904
28035
  if (sox < tox && sy1 >= toy) {
27905
28036
  return [
27906
28037
  { x: sox, y: soy },
27907
- { x: x$8, y: soy },
27908
- { x: x$8, y: toy }];
28038
+ { x: x$10, y: soy },
28039
+ { x: x$10, y: toy }];
27909
28040
  }
27910
28041
 
27911
- if (x$8 < smx1 && soy < ty1) {
27912
- var y$11 = Math.min(smy0, tmy0);
27913
- var x$9 = Math.min(smx0, tmx0);
28042
+ if (x$10 < smx1 && soy < ty1) {
28043
+ var y$13 = Math.min(smy0, tmy0);
28044
+ var x$11 = Math.min(smx0, tmx0);
27914
28045
  return [
27915
- { x: sox, y: y$11 },
27916
- { x: x$9, y: y$11 },
27917
- { x: x$9, y: toy }
28046
+ { x: sox, y: y$13 },
28047
+ { x: x$11, y: y$13 },
28048
+ { x: x$11, y: toy }
27918
28049
  ];
27919
28050
  }
28051
+
27920
28052
  return [
27921
28053
  { x: sox, y: soy },
27922
- { x: x$8, y: soy },
27923
- { x: x$8, y: toy }
28054
+ { x: x$10, y: soy },
28055
+ { x: x$10, y: toy }
27924
28056
  ];
27925
28057
  } else if (sourceSide === 'bottom' && targetSide === 'right') {
27926
- if (soy < toy) {
28058
+ var isPointInsideSource$4 = inflatedSourceBBox.containsPoint(targetPoint);
28059
+
28060
+ // The target point is inside the source element
28061
+ if (isPointInsideSource$4) {
28062
+ if (sox <= tmx1) {
28063
+ var x$12 = Math.max(sox + sourceMargin, tox);
28064
+ var y$14 = Math.max(smy1, tmy1);
28065
+
28066
+ // Target anchor is on the right side of the source anchor
28067
+ return [
28068
+ { x: sox, y: y$14 },
28069
+ { x: x$12, y: y$14 },
28070
+ { x: x$12, y: toy }
28071
+ ];
28072
+ }
28073
+
28074
+ // Target anchor is on the left side of the source anchor
28075
+ // Subtract the `sourceMargin` since the source anchor is on the right side of the target anchor
28076
+ var anchorMiddleX$2 = (sox - sourceMargin + tox) / 2;
28077
+
28078
+ return [
28079
+ { x: sox, y: soy },
28080
+ { x: anchorMiddleX$2, y: soy },
28081
+ { x: anchorMiddleX$2, y: toy }
28082
+ ];
28083
+ }
28084
+
28085
+ if (smy1 < toy) {
27927
28086
  if (sox < tox) {
27928
- var y$12 = middleOfHorizontalSides;
28087
+ var y$15 = tmy1;
27929
28088
 
27930
- if ((y$12 < tcy || !isSourceEl) && y$12 > tmy0 && sox < tx0) {
27931
- y$12 = tmy1;
28089
+ if (tmy0 >= smy1 && tmx1 >= sox) {
28090
+ y$15 = middleOfHorizontalSides;
27932
28091
  }
28092
+
27933
28093
  return [
27934
- { x: sox, y: y$12 },
27935
- { x: tox, y: y$12 },
28094
+ { x: sox, y: y$15 },
28095
+ { x: tox, y: y$15 },
27936
28096
  { x: tox, y: toy }
27937
28097
  ];
27938
28098
  }
28099
+
27939
28100
  return [{ x: sox, y: toy }];
27940
- } else {
27941
- if (sx0 < tox) {
27942
- var y$13 = Math.max(smy1, tmy1);
27943
- var x$10 = Math.max(smx1, tmx1);
27944
- return [
27945
- { x: sox, y: y$13 },
27946
- { x: x$10, y: y$13 },
27947
- { x: x$10, y: toy }
27948
- ];
27949
- }
27950
28101
  }
27951
28102
 
27952
- var x$11 = middleOfVerticalSides;
28103
+ var x$13 = Math.max(middleOfVerticalSides, tmx1);
28104
+
28105
+ if (sox > tox && sy0 <= toy) {
28106
+ return [
28107
+ { x: sox, y: soy },
28108
+ { x: x$13, y: soy },
28109
+ { x: x$13, y: toy }
28110
+ ];
28111
+ }
28112
+
28113
+ if (x$13 > smx0 && soy > ty0) {
28114
+ var y$16 = Math.max(smy1, tmy1);
28115
+ var x$14 = Math.max(smx1, tmx1);
28116
+ return [
28117
+ { x: sox, y: y$16 },
28118
+ { x: x$14, y: y$16 },
28119
+ { x: x$14, y: toy }
28120
+ ];
28121
+ }
27953
28122
 
27954
28123
  return [
27955
28124
  { x: sox, y: soy },
27956
- { x: x$11, y: soy },
27957
- { x: x$11, y: toy }
28125
+ { x: x$13, y: soy },
28126
+ { x: x$13, y: toy }
27958
28127
  ];
27959
28128
  } else if (sourceSide === 'bottom' && targetSide === 'left') {
27960
- if (soy < toy) {
28129
+ var isPointInsideSource$5 = inflatedSourceBBox.containsPoint(targetPoint);
28130
+
28131
+ // The target point is inside the source element
28132
+ if (isPointInsideSource$5) {
28133
+ if (sox >= tmx0) {
28134
+ var x$15 = Math.min(sox - sourceMargin, tox);
28135
+ var y$17 = Math.max(smy1, tmy1);
28136
+
28137
+ // Target anchor is on the left side of the source anchor
28138
+ return [
28139
+ { x: sox, y: y$17 },
28140
+ { x: x$15, y: y$17 },
28141
+ { x: x$15, y: toy }
28142
+ ];
28143
+ }
28144
+
28145
+ // Target anchor is on the right side of the source anchor
28146
+ // Add the `sourceMargin` since the source anchor is on the left side of the target anchor
28147
+ var anchorMiddleX$3 = (sox + sourceMargin + tox) / 2;
28148
+
28149
+ return [
28150
+ { x: sox, y: soy },
28151
+ { x: anchorMiddleX$3, y: soy },
28152
+ { x: anchorMiddleX$3, y: toy }
28153
+ ];
28154
+ }
28155
+
28156
+ if (smy1 < toy) {
27961
28157
  if (sox > tox) {
27962
- var y$14 = middleOfHorizontalSides;
28158
+ var y$18 = tmy1;
27963
28159
 
27964
- if ((y$14 < tcy || !isSourceEl) && y$14 > tmy0 && sox > tx1) {
27965
- y$14 = tmy1;
28160
+ if (tmy0 >= smy1 && tmx0 <= sox) {
28161
+ y$18 = middleOfHorizontalSides;
27966
28162
  }
28163
+
27967
28164
  return [
27968
- { x: sox, y: y$14 },
27969
- { x: tox, y: y$14 },
28165
+ { x: sox, y: y$18 },
28166
+ { x: tox, y: y$18 },
27970
28167
  { x: tox, y: toy }
27971
28168
  ];
27972
28169
  }
28170
+
27973
28171
  return [{ x: sox, y: toy }];
27974
- } else {
27975
- if (sx1 > tox) {
27976
- var y$15 = Math.max(smy1, tmy1);
27977
- var x$12 = Math.min(smx0, tmx0);
27978
- return [
27979
- { x: sox, y: y$15 },
27980
- { x: x$12, y: y$15 },
27981
- { x: x$12, y: toy }
27982
- ];
27983
- }
27984
28172
  }
27985
28173
 
27986
- var x$13 = middleOfVerticalSides;
28174
+ var x$16 = Math.min(tmx0, middleOfVerticalSides);
28175
+
28176
+ if (sox < tox && sy0 <= toy) {
28177
+ return [
28178
+ { x: sox, y: soy },
28179
+ { x: x$16, y: soy },
28180
+ { x: x$16, y: toy }
28181
+ ];
28182
+ }
28183
+
28184
+ if (x$16 < smx1 && soy > ty0) {
28185
+ var y$19 = Math.max(smy1, tmy1);
28186
+ var x$17 = Math.min(smx0, tmx0);
28187
+ return [
28188
+ { x: sox, y: y$19 },
28189
+ { x: x$17, y: y$19 },
28190
+ { x: x$17, y: toy }
28191
+ ];
28192
+ }
27987
28193
 
27988
28194
  return [
27989
28195
  { x: sox, y: soy },
27990
- { x: x$13, y: soy },
27991
- { x: x$13, y: toy }
28196
+ { x: x$16, y: soy },
28197
+ { x: x$16, y: toy }
27992
28198
  ];
27993
- }
27994
- else if (sourceSide === 'left' && targetSide === 'bottom') {
27995
- if (sox >= tox && soy >= tmy1) {
27996
- return [{ x: tox, y: soy }];
27997
- }
28199
+ } else if (sourceSide === 'left' && targetSide === 'bottom') {
28200
+ var isPointInsideSource$6 = inflatedSourceBBox.containsPoint(targetPoint);
27998
28201
 
27999
- if (sox >= tx1 && soy < toy) {
28000
- var x$14 = middleOfVerticalSides;
28202
+ // The target point is inside the source element
28203
+ if (isPointInsideSource$6) {
28204
+ if (soy <= tmy1) {
28205
+ var x$18 = Math.min(smx0, tmx0);
28206
+ var y$20 = Math.max(soy + sourceMargin, toy);
28207
+
28208
+ return [
28209
+ { x: x$18, y: soy },
28210
+ { x: x$18, y: y$20 },
28211
+ { x: tox, y: y$20 }
28212
+ ];
28213
+ }
28214
+
28215
+ // Target anchor is above the source anchor
28216
+ var anchorMiddleY = (soy - sourceMargin + toy) / 2;
28001
28217
 
28002
28218
  return [
28003
- { x: x$14, y: soy },
28004
- { x: x$14, y: toy },
28005
- { x: tox, y: toy }
28219
+ { x: sox, y: soy },
28220
+ { x: sox, y: anchorMiddleY },
28221
+ { x: tox, y: anchorMiddleY }
28006
28222
  ];
28007
28223
  }
28008
28224
 
28009
- if (tox < sx1 && ty1 <= sy0) {
28010
- var y$16 = middleOfHorizontalSides;
28225
+ if (smx0 > tox) {
28226
+ if (soy < toy) {
28227
+ var x$19 = tmx0;
28228
+
28229
+ if (tmx1 <= smx0 && tmy1 >= soy) {
28230
+ x$19 = middleOfVerticalSides;
28231
+ }
28232
+
28233
+ return [
28234
+ { x: x$19, y: soy },
28235
+ { x: x$19, y: toy },
28236
+ { x: tox, y: toy }
28237
+ ];
28238
+ }
28239
+
28240
+ return [{ x: tox, y: soy }];
28241
+ }
28242
+
28243
+ var y$21 = Math.max(tmy1, middleOfHorizontalSides);
28011
28244
 
28245
+ if (soy > toy && sx1 >= tox) {
28012
28246
  return [
28013
28247
  { x: sox, y: soy },
28014
- { x: sox, y: y$16 },
28015
- { x: tox, y: y$16 }
28248
+ { x: sox, y: y$21 },
28249
+ { x: tox, y: y$21 }
28016
28250
  ];
28017
28251
  }
28018
28252
 
28019
- var x$15 = Math.min(tmx0, sox);
28020
- var y$17 = Math.max(smy1, tmy1);
28253
+ if (y$21 > smy0 && sox < tx1) {
28254
+ var x$20 = Math.min(smx0, tmx0);
28255
+ var y$22 = Math.max(smy1, tmy1);
28256
+
28257
+ return [
28258
+ { x: x$20, y: soy },
28259
+ { x: x$20, y: y$22 },
28260
+ { x: tox, y: y$22 }
28261
+ ];
28262
+ }
28021
28263
 
28022
28264
  return [
28023
- { x: x$15, y: soy },
28024
- { x: x$15, y: y$17 },
28025
- { x: tox, y: y$17 }
28265
+ { x: sox, y: soy },
28266
+ { x: sox, y: y$21 },
28267
+ { x: tox, y: y$21 }
28026
28268
  ];
28027
28269
  } else if (sourceSide === 'left' && targetSide === 'top') {
28028
- if (sox > tox && soy < tmy0) {
28029
- return [{ x: tox, y: soy }];
28270
+ var isPointInsideSource$7 = inflatedSourceBBox.containsPoint(targetPoint);
28271
+
28272
+ // The target point is inside the source element
28273
+ if (isPointInsideSource$7) {
28274
+ if (soy >= tmy0) {
28275
+ var y$23 = Math.min(soy - sourceMargin, toy);
28276
+ var x$21 = Math.min(smx0, tmx0);
28277
+
28278
+ // Target anchor is on the top side of the source anchor
28279
+ return [
28280
+ { x: x$21, y: soy },
28281
+ { x: x$21, y: y$23 },
28282
+ { x: tox, y: y$23 }
28283
+ ];
28284
+ }
28285
+
28286
+ // Target anchor is below the source anchor
28287
+ // Add the `sourceMargin` since the source anchor is above the target anchor
28288
+ var anchorMiddleY$1 = (soy + sourceMargin + toy) / 2;
28289
+
28290
+ return [
28291
+ { x: sox, y: soy },
28292
+ { x: sox, y: anchorMiddleY$1 },
28293
+ { x: tox, y: anchorMiddleY$1 }
28294
+ ];
28030
28295
  }
28031
28296
 
28032
- if (sox >= tx1) {
28297
+ if (smx0 > tox) {
28033
28298
  if (soy > toy) {
28034
- var x$16 = middleOfVerticalSides;
28299
+ var x$22 = tmx0;
28300
+
28301
+ if (tmx1 <= smx0 && tmy0 <= soy) {
28302
+ x$22 = middleOfVerticalSides;
28303
+ }
28035
28304
 
28036
28305
  return [
28037
- { x: x$16, y: soy },
28038
- { x: x$16, y: toy },
28306
+ { x: x$22, y: soy },
28307
+ { x: x$22, y: toy },
28039
28308
  { x: tox, y: toy }
28040
28309
  ];
28041
28310
  }
28311
+
28312
+ return [{ x: tox, y: soy }];
28042
28313
  }
28043
28314
 
28044
- if (tox <= sx1 && toy > soy) {
28045
- var y$18 = middleOfHorizontalSides;
28315
+ var y$24 = Math.min(tmy0, middleOfHorizontalSides);
28046
28316
 
28317
+ if (soy < toy && sx1 >= tox) {
28047
28318
  return [
28048
28319
  { x: sox, y: soy },
28049
- { x: sox, y: y$18 },
28050
- { x: tox, y: y$18 } ];
28320
+ { x: sox, y: y$24 },
28321
+ { x: tox, y: y$24 }];
28051
28322
  }
28052
28323
 
28053
- var x$17 = toy < soy ? Math.min(smx0, tmx0) : smx0;
28054
- var y$19 = Math.min(smy0, tmy0);
28324
+ if (y$24 < smy1 && sox < tx1) {
28325
+ var x$23 = Math.min(smx0, tmx0);
28326
+ var y$25 = Math.min(smy0, tmy0);
28327
+ return [
28328
+ { x: x$23, y: soy },
28329
+ { x: x$23, y: y$25 },
28330
+ { x: tox, y: y$25 }
28331
+ ];
28332
+ }
28055
28333
 
28056
28334
  return [
28057
- { x: x$17, y: soy },
28058
- { x: x$17, y: y$19 },
28059
- { x: tox, y: y$19 }
28335
+ { x: sox, y: soy },
28336
+ { x: sox, y: y$24 },
28337
+ { x: tox, y: y$24 }
28060
28338
  ];
28061
-
28062
28339
  } else if (sourceSide === 'right' && targetSide === 'top') {
28063
- if (sox <= tox && soy < tmy0) {
28064
- return [{ x: tox, y: soy }];
28065
- }
28340
+ var isPointInsideSource$8 = inflatedSourceBBox.containsPoint(targetPoint);
28341
+
28342
+ // The target point is inside the source element
28343
+ if (isPointInsideSource$8) {
28344
+ if (soy >= tmy0) {
28345
+ var x$24 = Math.max(smx1, tmx1);
28346
+ var y$26 = Math.min(soy - sourceMargin, toy);
28347
+
28348
+ // Target anchor is on the top side of the source anchor
28349
+ return [
28350
+ { x: x$24, y: soy },
28351
+ { x: x$24, y: y$26 }, // Path adjustment for right side start
28352
+ { x: tox, y: y$26 }
28353
+ ];
28354
+ }
28066
28355
 
28067
- if (sx1 < tx0 && soy > toy) {
28068
- var x$18 = middleOfVerticalSides;
28356
+ // Target anchor is below the source anchor
28357
+ // Adjust sourceMargin calculation since the source anchor is now on the right
28358
+ var anchorMiddleY$2 = (soy + sourceMargin + toy) / 2;
28069
28359
 
28070
28360
  return [
28071
- { x: x$18, y: soy },
28072
- { x: x$18, y: toy },
28073
- { x: tox, y: toy }
28361
+ { x: sox, y: soy },
28362
+ { x: sox, y: anchorMiddleY$2 },
28363
+ { x: tox, y: anchorMiddleY$2 }
28074
28364
  ];
28075
28365
  }
28076
28366
 
28077
- if (tox < sox && ty0 > sy1) {
28078
- var y$20 = middleOfHorizontalSides;
28367
+ if (smx1 < tox) {
28368
+ if (soy > toy) {
28369
+ var x$25 = tmx1;
28079
28370
 
28371
+ if (tmx0 >= smx1 && tmy0 <= soy) {
28372
+ x$25 = middleOfVerticalSides;
28373
+ }
28374
+
28375
+ return [
28376
+ { x: x$25, y: soy },
28377
+ { x: x$25, y: toy },
28378
+ { x: tox, y: toy }
28379
+ ];
28380
+ }
28381
+
28382
+ return [{ x: tox, y: soy }];
28383
+ }
28384
+
28385
+ var y$27 = Math.min(tmy0, middleOfHorizontalSides);
28386
+
28387
+ if (soy < toy && sx0 <= tox) {
28080
28388
  return [
28081
28389
  { x: sox, y: soy },
28082
- { x: sox, y: y$20 },
28083
- { x: tox, y: y$20 }
28084
- ];
28390
+ { x: sox, y: y$27 },
28391
+ { x: tox, y: y$27 }];
28085
28392
  }
28086
28393
 
28087
- var x$19 = Math.max(smx1, tmx1);
28088
- var y$21 = Math.min(smy0, tmy0);
28394
+ if (y$27 < smy1 && sox > tx0) {
28395
+ var x$26 = Math.max(smx1, tmx1);
28396
+ var y$28 = Math.min(smy0, tmy0);
28397
+
28398
+ return [
28399
+ { x: x$26, y: soy },
28400
+ { x: x$26, y: y$28 },
28401
+ { x: tox, y: y$28 }
28402
+ ];
28403
+ }
28089
28404
 
28090
28405
  return [
28091
- { x: x$19, y: soy },
28092
- { x: x$19, y: y$21 },
28093
- { x: tox, y: y$21 }
28406
+ { x: sox, y: soy },
28407
+ { x: sox, y: y$27 },
28408
+ { x: tox, y: y$27 }
28094
28409
  ];
28095
28410
  } else if (sourceSide === 'right' && targetSide === 'bottom') {
28096
- if (sox <= tox && soy >= tmy1) {
28097
- return [{ x: tox, y: soy }];
28098
- }
28411
+ var isPointInsideSource$9 = inflatedSourceBBox.containsPoint(targetPoint);
28099
28412
 
28100
- if (sox <= tmx0 && soy < toy) {
28101
- var x$20 = middleOfVerticalSides;
28413
+ // The target point is inside the source element
28414
+ if (isPointInsideSource$9) {
28415
+ if (soy <= tmy1) {
28416
+ var x$27 = Math.max(smx1, tmx1);
28417
+ var y$29 = Math.max(soy + sourceMargin, toy);
28418
+
28419
+ return [
28420
+ { x: x$27, y: soy },
28421
+ { x: x$27, y: y$29 },
28422
+ { x: tox, y: y$29 }
28423
+ ];
28424
+ }
28425
+
28426
+ // Target anchor is above the source anchor
28427
+ var anchorMiddleY$3 = (soy - sourceMargin + toy) / 2;
28102
28428
 
28103
28429
  return [
28104
- { x: x$20, y: soy },
28105
- { x: x$20, y: toy },
28106
- { x: tox, y: toy }
28430
+ { x: sox, y: soy },
28431
+ { x: sox, y: anchorMiddleY$3 },
28432
+ { x: tox, y: anchorMiddleY$3 }
28107
28433
  ];
28108
28434
  }
28109
28435
 
28110
- if (tox > sx0 && ty1 < sy0) {
28111
- var y$22 = middleOfHorizontalSides;
28436
+ if (smx1 < tox) {
28437
+ if (soy < toy) {
28438
+ var x$28 = tmx1;
28439
+
28440
+ if (tmx0 >= smx1 && tmy1 >= soy) {
28441
+ x$28 = middleOfVerticalSides;
28442
+ }
28443
+
28444
+ return [
28445
+ { x: x$28, y: soy },
28446
+ { x: x$28, y: toy },
28447
+ { x: tox, y: toy }
28448
+ ];
28449
+ }
28450
+
28451
+ return [{ x: tox, y: soy }];
28452
+ }
28453
+
28454
+ var y$30 = Math.max(tmy1, middleOfHorizontalSides);
28112
28455
 
28456
+ if (soy > toy && sx0 <= tox) {
28113
28457
  return [
28114
28458
  { x: sox, y: soy },
28115
- { x: sox, y: y$22 },
28116
- { x: tox, y: y$22 }
28459
+ { x: sox, y: y$30 },
28460
+ { x: tox, y: y$30 }
28117
28461
  ];
28118
28462
  }
28119
28463
 
28120
- var x$21 = Math.max(tmx1, sox);
28121
- var y$23 = Math.max(smy1, tmy1);
28464
+ if (y$30 > smy0 && sox > tx0) {
28465
+ var x$29 = Math.max(smx1, tmx1);
28466
+ var y$31 = Math.max(smy1, tmy1);
28467
+
28468
+ return [
28469
+ { x: x$29, y: soy },
28470
+ { x: x$29, y: y$31 },
28471
+ { x: tox, y: y$31 }
28472
+ ];
28473
+ }
28122
28474
 
28123
28475
  return [
28124
- { x: x$21, y: soy },
28125
- { x: x$21, y: y$23 },
28126
- { x: tox, y: y$23 }
28476
+ { x: sox, y: soy },
28477
+ { x: sox, y: y$30 },
28478
+ { x: tox, y: y$30 }
28127
28479
  ];
28128
28480
  }
28129
28481
  }
@@ -28159,7 +28511,7 @@ var joint = (function (exports) {
28159
28511
  dummySource.direction = fromDirection;
28160
28512
  firstVertex.direction = toDirection;
28161
28513
 
28162
- resultVertices.push.apply(resultVertices, routeBetweenPoints(dummySource, firstVertex).concat( [firstVertex.point] ));
28514
+ resultVertices.push.apply(resultVertices, routeBetweenPoints(dummySource, firstVertex, { targetInSourceBBox: true }).concat( [firstVertex.point] ));
28163
28515
  } else {
28164
28516
  // The first point responsible for the initial direction of the route
28165
28517
  var next = verticesData[1] || targetPoint;
@@ -30260,13 +30612,18 @@ var joint = (function (exports) {
30260
30612
 
30261
30613
  var model = this.model;
30262
30614
  var id = model.id;
30263
- var port = this.findAttribute('port', magnet);
30615
+ // Find a node with the `port` attribute set on it.
30616
+ var portNode = this.findAttributeNode('port', magnet);
30264
30617
  // Find a unique `selector` of the element under pointer that is a magnet.
30265
30618
  var selector = magnet.getAttribute('joint-selector');
30266
30619
 
30267
30620
  var end = { id: id };
30268
30621
  if (selector != null) { end.magnet = selector; }
30269
- if (port != null) {
30622
+ if (portNode != null) {
30623
+ var port = portNode.getAttribute('port');
30624
+ if (portNode.getAttribute('port-id-type') === 'number') {
30625
+ port = parseInt(port, 10);
30626
+ }
30270
30627
  end.port = port;
30271
30628
  if (!model.hasPort(port) && !selector) {
30272
30629
  // port created via the `port` attribute (not API)
@@ -34321,6 +34678,8 @@ var joint = (function (exports) {
34321
34678
  },
34322
34679
 
34323
34680
  renderGrid: function renderGrid() {
34681
+ var this$1 = this;
34682
+
34324
34683
 
34325
34684
  var ref = this;
34326
34685
  var paper = ref.options.paper;
@@ -34340,7 +34699,7 @@ var joint = (function (exports) {
34340
34699
 
34341
34700
  gridSettings.forEach(function (gridLayerSetting, index) {
34342
34701
 
34343
- var id = 'pattern_' + index;
34702
+ var id = this$1._getPatternId(index);
34344
34703
  var options = merge({}, gridLayerSetting);
34345
34704
  var scaleFactor = options.scaleFactor; if ( scaleFactor === void 0 ) scaleFactor = 1;
34346
34705
  options.width = gridSize * scaleFactor || 1;
@@ -34368,6 +34727,8 @@ var joint = (function (exports) {
34368
34727
  },
34369
34728
 
34370
34729
  updateGrid: function updateGrid() {
34730
+ var this$1 = this;
34731
+
34371
34732
 
34372
34733
  var ref = this;
34373
34734
  var grid = ref._gridCache;
@@ -34388,12 +34749,16 @@ var joint = (function (exports) {
34388
34749
  }
34389
34750
  gridSettings.forEach(function (options, index) {
34390
34751
  if (isFunction(options.update)) {
34391
- var vPattern = patterns['pattern_' + index];
34752
+ var vPattern = patterns[this$1._getPatternId(index)];
34392
34753
  options.update(vPattern.node.firstChild, options, paper);
34393
34754
  }
34394
34755
  });
34395
34756
  },
34396
34757
 
34758
+ _getPatternId: function _getPatternId(index) {
34759
+ return ("pattern_" + (this.options.paper.cid) + "_" + index);
34760
+ },
34761
+
34397
34762
  _getGridRefs: function _getGridRefs() {
34398
34763
  var ref = this;
34399
34764
  var grid = ref._gridCache;
@@ -34823,6 +35188,8 @@ var joint = (function (exports) {
34823
35188
  },
34824
35189
 
34825
35190
  _resetUpdates: function() {
35191
+ if (this._updates && this._updates.id) { cancelFrame(this._updates.id); }
35192
+
34826
35193
  return this._updates = {
34827
35194
  id: null,
34828
35195
  priorities: [{}, {}, {}],
@@ -38616,12 +38983,14 @@ var joint = (function (exports) {
38616
38983
  evt.stopPropagation();
38617
38984
  evt.preventDefault();
38618
38985
  var relatedView = this.relatedView;
38986
+ var paper = relatedView.paper;
38619
38987
  relatedView.model.startBatch('arrowhead-move', { ui: true, tool: this.cid });
38620
38988
  relatedView.startArrowheadMove(this.arrowheadType);
38621
38989
  this.delegateDocumentEvents();
38622
- relatedView.paper.undelegateEvents();
38990
+ paper.undelegateEvents();
38623
38991
  this.focus();
38624
38992
  this.el.style.pointerEvents = 'none';
38993
+ relatedView.notifyPointerdown.apply(relatedView, paper.getPointerArgs(evt));
38625
38994
  },
38626
38995
  onPointerMove: function(evt) {
38627
38996
  var normalizedEvent = normalizeEvent(evt);
@@ -39576,7 +39945,7 @@ var joint = (function (exports) {
39576
39945
  Control: Control
39577
39946
  });
39578
39947
 
39579
- var version = "4.0.1";
39948
+ var version = "4.0.3";
39580
39949
 
39581
39950
  var Vectorizer = V;
39582
39951
  var layout = { PortLabel: PortLabel, Port: Port };