@teachinglab/omd 0.2.7 → 0.2.8

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.
@@ -6,10 +6,11 @@ import { omdStepVisualizerInteractiveSteps } from '../utils/omdStepVisualizerInt
6
6
  * Handles creation, positioning, and cleanup of explanation popups
7
7
  */
8
8
  export class omdStepVisualizerTextBoxes {
9
- constructor(stepVisualizer, highlighting) {
9
+ constructor(stepVisualizer, highlighting, options = {}) {
10
10
  this.stepVisualizer = stepVisualizer;
11
11
  this.highlighting = highlighting;
12
12
  this.stepTextBoxes = [];
13
+ this.options = options;
13
14
  }
14
15
 
15
16
  /**
@@ -42,7 +43,11 @@ export class omdStepVisualizerTextBoxes {
42
43
  * @private
43
44
  */
44
45
  _createInteractiveStepsForDot(dotIndex, targetDot, simplificationData) {
45
- const interactiveSteps = new omdStepVisualizerInteractiveSteps(this.stepVisualizer, simplificationData);
46
+ const interactiveSteps = new omdStepVisualizerInteractiveSteps(
47
+ this.stepVisualizer,
48
+ simplificationData,
49
+ this.options // Pass styling options to interactive steps
50
+ );
46
51
 
47
52
  // Position relative to the target dot
48
53
  const x = targetDot.xpos + this.stepVisualizer.dotRadius * 2 + 10;
@@ -62,14 +67,26 @@ export class omdStepVisualizerTextBoxes {
62
67
  layoutGroup.dotIndex = dotIndex;
63
68
  this.stepVisualizer.visualContainer.addChild(layoutGroup);
64
69
 
70
+ // Apply configured z-index styling to ensure proper layering
71
+ if (layoutGroup.svgObject && (this.options.zIndex || this.options.position)) {
72
+ if (this.options.position) {
73
+ layoutGroup.svgObject.style.position = this.options.position;
74
+ }
75
+ if (this.options.zIndex) {
76
+ layoutGroup.svgObject.style.zIndex = String(this.options.zIndex);
77
+
78
+ // Only apply to the main container, NOT to child elements to preserve internal layout
79
+ // Applying position absolute to child elements breaks flexbox layout
80
+ }
81
+ }
82
+
65
83
  this.stepTextBoxes.push({
66
84
  dotIndex: dotIndex,
67
85
  interactiveSteps: interactiveSteps,
68
86
  layoutGroup: layoutGroup
69
87
  });
70
88
 
71
- // Update layout to prevent clipping after adding text box
72
- this.stepVisualizer.layoutManager.updateVisualLayout();
89
+ // Note: Removed updateVisualLayout call to prevent repositioning movement
73
90
  }
74
91
 
75
92
 
@@ -88,8 +105,7 @@ export class omdStepVisualizerTextBoxes {
88
105
  item.interactiveSteps.destroy();
89
106
  this.stepTextBoxes.splice(textBoxIndex, 1);
90
107
 
91
- // Update layout after removing text box to adjust container size
92
- this.stepVisualizer.layoutManager.updateVisualLayout();
108
+ // Note: Removed updateVisualLayout call to prevent repositioning movement
93
109
  }
94
110
  }
95
111
 
@@ -103,8 +119,7 @@ export class omdStepVisualizerTextBoxes {
103
119
  });
104
120
  this.stepTextBoxes = [];
105
121
 
106
- // Update layout after clearing all text boxes
107
- this.stepVisualizer.layoutManager.updateVisualLayout();
122
+ // Note: Removed updateVisualLayout call to prevent repositioning movement
108
123
  }
109
124
 
110
125
  /**
@@ -160,4 +175,27 @@ export class omdStepVisualizerTextBoxes {
160
175
  getStepTextBoxes() {
161
176
  return this.stepTextBoxes;
162
177
  }
178
+
179
+ /**
180
+ * Updates the styling options for text boxes
181
+ * @param {Object} newOptions - New styling options
182
+ */
183
+ updateStyling(newOptions = {}) {
184
+ this.options = { ...this.options, ...newOptions };
185
+
186
+ // Apply new styling to existing text boxes
187
+ this.stepTextBoxes.forEach(textBoxItem => {
188
+ if (textBoxItem.interactiveSteps && typeof textBoxItem.interactiveSteps.updateStyling === 'function') {
189
+ textBoxItem.interactiveSteps.updateStyling(this.options);
190
+ }
191
+ });
192
+ }
193
+
194
+ /**
195
+ * Gets the current styling options
196
+ * @returns {Object} Current styling options
197
+ */
198
+ getStyling() {
199
+ return { ...this.options };
200
+ }
163
201
  }