@vanduo-oss/framework 1.4.6 → 1.5.0

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
- /*! Vanduo v1.4.6 | Built: 2026-06-13T10:32:26.875Z | git:82019ff | development */
1
+ /*! Vanduo v1.5.0 | Built: 2026-06-18T19:13:58.613Z | git:8f0e1b5 | development */
2
2
 
3
3
  // js/utils/lifecycle.js
4
4
  (function() {
@@ -176,7 +176,7 @@
176
176
  // js/vanduo.js
177
177
  (function() {
178
178
  "use strict";
179
- const VANDUO_VERSION = true ? "1.4.6" : "0.0.0-dev";
179
+ const VANDUO_VERSION = true ? "1.5.0" : "0.0.0-dev";
180
180
  const hasOwn = Object.prototype.hasOwnProperty;
181
181
  const Vanduo2 = {
182
182
  version: VANDUO_VERSION,
@@ -10416,6 +10416,7 @@
10416
10416
  _cleanup: [],
10417
10417
  _boundTriggers: /* @__PURE__ */ new WeakMap(),
10418
10418
  _triggerElement: null,
10419
+ _currentTarget: null,
10419
10420
  init: function(root) {
10420
10421
  const triggers = window.Vanduo.queryAll(root, "[data-vd-spotlight]");
10421
10422
  triggers.forEach((trigger) => {
@@ -10484,8 +10485,29 @@
10484
10485
  document.addEventListener("keydown", escHandler);
10485
10486
  this._cleanup.push(() => document.removeEventListener("keydown", escHandler));
10486
10487
  overlay.addEventListener("click", () => this.stop());
10488
+ const reposition = () => {
10489
+ if (this._active && this._currentTarget) this._positionTooltip(this._currentTarget);
10490
+ };
10491
+ window.addEventListener("scroll", reposition, { passive: true });
10492
+ window.addEventListener("resize", reposition);
10493
+ this._cleanup.push(() => window.removeEventListener("scroll", reposition));
10494
+ this._cleanup.push(() => window.removeEventListener("resize", reposition));
10487
10495
  this._showStep(this._currentStep);
10488
10496
  },
10497
+ _positionTooltip: function(target) {
10498
+ const tooltip = this._elements.tooltip;
10499
+ if (!tooltip || !target || !target.isConnected) return;
10500
+ const rect = target.getBoundingClientRect();
10501
+ const tRect = tooltip.getBoundingClientRect();
10502
+ let top = rect.bottom + 12 + window.scrollY;
10503
+ let left = rect.left + (rect.width - tRect.width) / 2 + window.scrollX;
10504
+ left = Math.max(8, Math.min(left, window.innerWidth - tRect.width - 8));
10505
+ if (top + tRect.height > window.innerHeight + window.scrollY) {
10506
+ top = rect.top - tRect.height - 12 + window.scrollY;
10507
+ }
10508
+ tooltip.style.top = top + "px";
10509
+ tooltip.style.left = left + "px";
10510
+ },
10489
10511
  _showStep: function(index) {
10490
10512
  const step = this._steps[index];
10491
10513
  if (!step) return;
@@ -10558,19 +10580,15 @@
10558
10580
  footer.appendChild(counter);
10559
10581
  footer.appendChild(actions);
10560
10582
  tooltip.appendChild(footer);
10583
+ this._currentTarget = target || null;
10561
10584
  if (target) {
10562
- requestAnimationFrame(() => {
10563
- const rect = target.getBoundingClientRect();
10564
- const tRect = tooltip.getBoundingClientRect();
10565
- let top = rect.bottom + 12 + window.scrollY;
10566
- let left = rect.left + (rect.width - tRect.width) / 2 + window.scrollX;
10567
- left = Math.max(8, Math.min(left, window.innerWidth - tRect.width - 8));
10568
- if (top + tRect.height > window.innerHeight + window.scrollY) {
10569
- top = rect.top - tRect.height - 12 + window.scrollY;
10570
- }
10571
- tooltip.style.top = top + "px";
10572
- tooltip.style.left = left + "px";
10573
- });
10585
+ let frames = 0;
10586
+ const settle = () => {
10587
+ if (!this._active || this._currentTarget !== target) return;
10588
+ this._positionTooltip(target);
10589
+ if (frames++ < 30) requestAnimationFrame(settle);
10590
+ };
10591
+ requestAnimationFrame(settle);
10574
10592
  }
10575
10593
  document.dispatchEvent(new CustomEvent("spotlight:step", {
10576
10594
  detail: { index, step: index, total, data: step }
@@ -10611,6 +10629,7 @@
10611
10629
  this._elements = {};
10612
10630
  this._steps = [];
10613
10631
  this._currentStep = 0;
10632
+ this._currentTarget = null;
10614
10633
  if (this._triggerElement && this._triggerElement.isConnected && typeof this._triggerElement.focus === "function") {
10615
10634
  this._triggerElement.focus();
10616
10635
  }