capdag 0.182.459 → 0.184.465

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.
Files changed (2) hide show
  1. package/cap-fab-renderer.js +27 -16
  2. package/package.json +1 -1
@@ -2590,6 +2590,22 @@ class CapFabRenderer {
2590
2590
  // viewport (≈15% slack at 800×600).
2591
2591
  static get ZOOM_OUT_FIT_SLACK() { return 0.15; }
2592
2592
 
2593
+ // Fit padding must scale down in very short viewports. The compact
2594
+ // machine-select graph pane is only ~100px tall; a fixed 50px inset
2595
+ // leaves no vertical room, so the bootstrap fit degenerates and the
2596
+ // graph opens at Cytoscape's fallback zoom instead of a true fit.
2597
+ // Keep the requested desktop padding where there is room, but cap it
2598
+ // to a small fraction of the actual visible viewport in compact
2599
+ // hosts.
2600
+ _resolvedFitPadding(requestedPadding, containerWidth, containerHeight, excluded) {
2601
+ const requested = Math.max(0, requestedPadding | 0);
2602
+ const availableHeight = Math.max(0, containerHeight - excluded);
2603
+ const limitingDim = Math.max(0, Math.min(containerWidth, availableHeight));
2604
+ if (limitingDim <= 0) return 0;
2605
+ const capped = Math.floor(limitingDim * 0.12);
2606
+ return Math.max(0, Math.min(requested, capped));
2607
+ }
2608
+
2593
2609
  // Bootstrap fit: snap (no animation) to a centered, padded fit of
2594
2610
  // the entire graph. Used during the first paint and the post-paint
2595
2611
  // resize ticks while `_initialFitDone` is false. The padding here
@@ -2612,11 +2628,11 @@ class CapFabRenderer {
2612
2628
  if (containerWidth <= 0 || containerHeight <= 0) return;
2613
2629
  const elements = cy.elements();
2614
2630
  if (elements.length === 0) return;
2615
- const bb = elements.boundingBox();
2631
+ const bb = elements.boundingBox({ includeLabels: true, includeOverlays: false });
2616
2632
  if (bb.w === 0 && bb.h === 0) return;
2617
2633
 
2618
- const padding = 50;
2619
2634
  const excluded = Math.max(0, this.bottomExcludedRegion() | 0);
2635
+ const padding = this._resolvedFitPadding(50, containerWidth, containerHeight, excluded);
2620
2636
  const visibleWidth = containerWidth - padding * 2;
2621
2637
  const visibleHeight = containerHeight - excluded - padding * 2;
2622
2638
  if (visibleWidth <= 0 || visibleHeight <= 0) return;
@@ -2642,12 +2658,9 @@ class CapFabRenderer {
2642
2658
  // our zoom/pan write and leave the graph drifting.
2643
2659
  cy.stop(true);
2644
2660
  this._internalPanZoom = true;
2645
- try {
2646
- cy.zoom(clampedZoom);
2647
- cy.pan({ x: panX, y: panY });
2648
- } finally {
2649
- this._internalPanZoom = false;
2650
- }
2661
+ cy.zoom(clampedZoom);
2662
+ cy.pan({ x: panX, y: panY });
2663
+ this._internalPanZoom = false;
2651
2664
  }
2652
2665
 
2653
2666
  // Mark the bootstrap centering as complete so subsequent refits
@@ -2687,7 +2700,7 @@ class CapFabRenderer {
2687
2700
  // that sits comfortably above this relaxed minimum, so opening
2688
2701
  // the view shows the graph centred with margin rather than
2689
2702
  // bleeding to all four edges.
2690
- const bb = this.cy.elements().boundingBox();
2703
+ const bb = this.cy.elements().boundingBox({ includeLabels: true, includeOverlays: false });
2691
2704
  let zoomMin;
2692
2705
  if (bb.w > 0 && bb.h > 0) {
2693
2706
  const strictFit = Math.min(w / bb.w, h / bb.h);
@@ -3392,12 +3405,13 @@ class CapFabRenderer {
3392
3405
  this.cy.stop(true);
3393
3406
  if (!eles || eles.length === 0) eles = this.cy.elements();
3394
3407
 
3395
- const bb = eles.boundingBox();
3408
+ const bb = eles.boundingBox({ includeLabels: true, includeOverlays: false });
3396
3409
  if (bb.w === 0 && bb.h === 0) return;
3397
3410
 
3398
3411
  const containerWidth = this.cy.width();
3399
3412
  const containerHeight = this.cy.height();
3400
3413
  const excluded = Math.max(0, this.bottomExcludedRegion() | 0);
3414
+ padding = this._resolvedFitPadding(padding, containerWidth, containerHeight, excluded);
3401
3415
 
3402
3416
  const visibleWidth = containerWidth - padding * 2;
3403
3417
  const visibleHeight = containerHeight - excluded - padding * 2;
@@ -3428,12 +3442,9 @@ class CapFabRenderer {
3428
3442
  stop: () => { this._internalPanZoom = false; },
3429
3443
  });
3430
3444
  } else {
3431
- try {
3432
- this.cy.zoom(clampedZoom);
3433
- this.cy.pan({ x: panX, y: panY });
3434
- } finally {
3435
- this._internalPanZoom = false;
3436
- }
3445
+ this.cy.zoom(clampedZoom);
3446
+ this.cy.pan({ x: panX, y: panY });
3447
+ this._internalPanZoom = false;
3437
3448
  }
3438
3449
  }
3439
3450
 
package/package.json CHANGED
@@ -40,5 +40,5 @@
40
40
  "pretest": "npm run build:parser",
41
41
  "test": "node capdag.test.js"
42
42
  },
43
- "version": "0.182.459"
43
+ "version": "0.184.465"
44
44
  }