@vectoriox/iox-builder 1.7.6 → 1.7.7

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.
@@ -2608,6 +2608,8 @@ class MoveableCanvasService {
2608
2608
  this.sourceId = this.resolveDropzoneId(element);
2609
2609
  this.ensureMoveable();
2610
2610
  this.moveable.target = element;
2611
+ // Snap against sibling/cousin nodes (not self, ancestors, or own descendants).
2612
+ this.moveable.elementGuidelines = this.guidelines(element);
2611
2613
  // Drag is initiated by grabbing the ELEMENT itself (like interact.js) — not a Moveable
2612
2614
  // overlay area — so a plain click still passes through to selection/child-selection and only
2613
2615
  // a movement past the threshold starts a drag. Keeps Moveable visually silent (no hit-area box).
@@ -2616,6 +2618,14 @@ class MoveableCanvasService {
2616
2618
  }
2617
2619
  /** Recompute the control-box position (call on scroll/zoom/layout changes). */
2618
2620
  refresh() { this.moveable?.updateRect(); }
2621
+ /** Snap guideline elements for `target`: every node host except itself, its ancestors, and its
2622
+ * own descendants — i.e. siblings/cousins to align edges/centers against. */
2623
+ guidelines(target) {
2624
+ if (!this.container)
2625
+ return [];
2626
+ const all = Array.from(this.container.querySelectorAll('[class*="iox-node-"]'));
2627
+ return all.filter(el => el !== target && !target.contains(el) && !el.contains(target));
2628
+ }
2619
2629
  destroy() { this.destroyMoveable(); this.container = null; }
2620
2630
  // ── internals ────────────────────────────────────────────────────────────
2621
2631
  ensureMoveable() {
@@ -2635,6 +2645,14 @@ class MoveableCanvasService {
2635
2645
  hideDefaultLines: true,
2636
2646
  renderDirections: ['nw', 'ne', 'sw', 'se'],
2637
2647
  className: 'iox-moveable-silent',
2648
+ // Snap-to-guides: align edges/centers to sibling elements while dragging/resizing, with
2649
+ // the distance readout. elementGuidelines are refreshed per selection (see select()).
2650
+ snappable: true,
2651
+ snapThreshold: 6,
2652
+ snapDirections: { top: true, left: true, bottom: true, right: true, center: true, middle: true },
2653
+ elementSnapDirections: { top: true, left: true, bottom: true, right: true, center: true, middle: true },
2654
+ snapGap: true,
2655
+ isDisplaySnapDigit: true,
2638
2656
  });
2639
2657
  this.moveable.on('dragStart', (e) => {
2640
2658
  // Never start a drag from inside inline text editing.