@vectoriox/iox-builder 1.4.21 → 1.4.22

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.
@@ -1090,6 +1090,12 @@ class InteractionEngineService {
1090
1090
  this.attached = new Map();
1091
1091
  /** Elements that have had pre-state applied (hidden by attach). */
1092
1092
  this.preStatedElements = new Set();
1093
+ /**
1094
+ * Pre-states queued for elements that weren't registered yet when the owner
1095
+ * node's attach() ran. Keyed by target node ID. Consumed when the target
1096
+ * element's own attach() fires.
1097
+ */
1098
+ this.pendingPreStates = new Map();
1093
1099
  /** Action types that animate an element from hidden → visible. */
1094
1100
  this.ENTRANCE_TYPES = new Set([
1095
1101
  'fadeIn', 'moveUp', 'moveDown', 'moveLeft', 'moveRight', 'scaleIn', 'show',
@@ -1099,22 +1105,40 @@ class InteractionEngineService {
1099
1105
  }
1100
1106
  /** Wire all interactions for a node to its rendered DOM element. */
1101
1107
  attach(node) {
1102
- if (!node.interactions?.length)
1103
- return;
1104
1108
  const ref = this.overlayService.getNodeRef(node);
1105
1109
  if (!ref)
1106
1110
  return;
1111
+ // Apply any pre-states that were queued by other nodes that target THIS
1112
+ // element with an entrance animation but registered before we did.
1113
+ if (node.id) {
1114
+ const pending = this.pendingPreStates.get(node.id);
1115
+ if (pending) {
1116
+ for (const action of pending) {
1117
+ this.applyPreState(ref.element, action);
1118
+ }
1119
+ this.pendingPreStates.delete(node.id);
1120
+ }
1121
+ }
1122
+ if (!node.interactions?.length)
1123
+ return;
1107
1124
  const cleanups = [];
1108
1125
  for (const ix of node.interactions) {
1109
1126
  // Apply pre-state to targets of ANY entrance animation so the element
1110
1127
  // starts hidden regardless of whether the trigger is automatic (pageLoad,
1111
- // viewportEnter) or user-driven (click). Without this, a click-triggered
1112
- // fadeIn on a menu overlay would start the overlay fully visible.
1128
+ // viewportEnter) or user-driven (click).
1113
1129
  for (const action of ix.actions) {
1114
1130
  if (this.ENTRANCE_TYPES.has(action.type)) {
1115
1131
  const target = this.resolveTarget(node, action);
1116
- if (target)
1132
+ if (target) {
1117
1133
  this.applyPreState(target, action);
1134
+ }
1135
+ else if (action.target && action.target !== 'self') {
1136
+ // Target element not registered yet — queue the pre-state so
1137
+ // it gets applied the moment that element's attach() fires.
1138
+ const list = this.pendingPreStates.get(action.target) ?? [];
1139
+ list.push(action);
1140
+ this.pendingPreStates.set(action.target, list);
1141
+ }
1118
1142
  }
1119
1143
  }
1120
1144
  const cleanup = this.attachInteraction(node, ix, ref.element);
@@ -1142,6 +1166,20 @@ class InteractionEngineService {
1142
1166
  if (node.interactions) {
1143
1167
  for (const ix of node.interactions) {
1144
1168
  for (const action of ix.actions) {
1169
+ // Remove any pending pre-states for unregistered targets.
1170
+ if (action.target && action.target !== 'self') {
1171
+ const pending = this.pendingPreStates.get(action.target);
1172
+ if (pending) {
1173
+ const filtered = pending.filter(a => a !== action);
1174
+ if (filtered.length) {
1175
+ this.pendingPreStates.set(action.target, filtered);
1176
+ }
1177
+ else {
1178
+ this.pendingPreStates.delete(action.target);
1179
+ }
1180
+ }
1181
+ }
1182
+ // Clean up inline styles on already-registered target elements.
1145
1183
  const target = this.resolveTarget(node, action);
1146
1184
  if (target && this.preStatedElements.has(target)) {
1147
1185
  target.getAnimations().forEach(a => a.cancel());