@teachinglab/omd 0.3.0 → 0.3.2
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.
- package/docs/api/configuration-options.md +198 -198
- package/docs/api/eventManager.md +82 -82
- package/docs/api/focusFrameManager.md +144 -144
- package/docs/api/index.md +105 -105
- package/docs/api/main.md +62 -62
- package/docs/api/omdBinaryExpressionNode.md +86 -86
- package/docs/api/omdCanvas.md +83 -83
- package/docs/api/omdConfigManager.md +112 -112
- package/docs/api/omdConstantNode.md +52 -52
- package/docs/api/omdDisplay.md +87 -87
- package/docs/api/omdEquationNode.md +174 -174
- package/docs/api/omdEquationSequenceNode.md +258 -258
- package/docs/api/omdEquationStack.md +156 -156
- package/docs/api/omdFunctionNode.md +82 -82
- package/docs/api/omdGroupNode.md +78 -78
- package/docs/api/omdHelpers.md +87 -87
- package/docs/api/omdLeafNode.md +85 -85
- package/docs/api/omdNode.md +201 -201
- package/docs/api/omdOperationDisplayNode.md +117 -117
- package/docs/api/omdOperatorNode.md +91 -91
- package/docs/api/omdParenthesisNode.md +133 -133
- package/docs/api/omdPopup.md +191 -191
- package/docs/api/omdPowerNode.md +131 -131
- package/docs/api/omdRationalNode.md +144 -144
- package/docs/api/omdSimplification.md +78 -78
- package/docs/api/omdSqrtNode.md +144 -144
- package/docs/api/omdStepVisualizer.md +146 -146
- package/docs/api/omdStepVisualizerHighlighting.md +65 -65
- package/docs/api/omdStepVisualizerInteractiveSteps.md +108 -108
- package/docs/api/omdStepVisualizerLayout.md +70 -70
- package/docs/api/omdStepVisualizerTextBoxes.md +76 -76
- package/docs/api/omdTranscriptionService.md +95 -95
- package/docs/api/omdTreeDiff.md +169 -169
- package/docs/api/omdUnaryExpressionNode.md +137 -137
- package/docs/api/omdUtilities.md +82 -82
- package/docs/api/omdVariableNode.md +123 -123
- package/omd/nodes/omdConstantNode.js +141 -141
- package/omd/nodes/omdGroupNode.js +67 -67
- package/omd/nodes/omdLeafNode.js +76 -76
- package/omd/nodes/omdOperatorNode.js +108 -108
- package/omd/nodes/omdParenthesisNode.js +292 -292
- package/omd/nodes/omdPowerNode.js +235 -235
- package/omd/nodes/omdRationalNode.js +295 -295
- package/omd/nodes/omdVariableNode.js +122 -122
- package/omd/simplification/omdSimplification.js +140 -140
- package/omd/step-visualizer/omdStepVisualizer.js +947 -947
- package/omd/step-visualizer/omdStepVisualizerLayout.js +892 -892
- package/package.json +2 -1
- package/src/index.js +11 -0
- package/src/omdBalanceHanger.js +2 -1
- package/src/omdEquation.js +1 -1
- package/src/omdNumber.js +1 -1
- package/src/omdNumberLine.js +13 -7
- package/src/omdRatioChart.js +19 -0
- package/src/omdShapes.js +1 -1
- package/src/omdTapeDiagram.js +1 -1
- package/src/omdTerm.js +1 -1
|
@@ -1,109 +1,109 @@
|
|
|
1
|
-
# omdStepVisualizerInteractiveSteps
|
|
2
|
-
|
|
3
|
-
This class creates and manages the interactive text boxes that display detailed explanations for simplification steps within the `omdStepVisualizer`. It formats the messages, handles styling, and sets up hover and click interactions, allowing users to explore the mathematical transformations.
|
|
4
|
-
|
|
5
|
-
## Class Definition
|
|
6
|
-
|
|
7
|
-
```javascript
|
|
8
|
-
export class omdStepVisualizerInteractiveSteps
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Constructor
|
|
12
|
-
|
|
13
|
-
### `new omdStepVisualizerInteractiveSteps(stepVisualizer, simplificationData)`
|
|
14
|
-
|
|
15
|
-
Creates a new `omdStepVisualizerInteractiveSteps` instance.
|
|
16
|
-
|
|
17
|
-
- **`stepVisualizer`** (`omdStepVisualizer`): A reference to the `omdStepVisualizer` instance this component is associated with.
|
|
18
|
-
- **`simplificationData`** (`object`): An object containing the simplification details for the step, typically including `message`, `rawMessages`, `ruleNames`, and potentially `operationValueNode`.
|
|
19
|
-
|
|
20
|
-
During construction, it extracts and cleans messages and rule names from the `simplificationData`, initializes layout properties (like `stepWidth`, `fontSize`), sets up the main `layoutGroup`, and creates the individual step elements.
|
|
21
|
-
|
|
22
|
-
## Public Properties
|
|
23
|
-
|
|
24
|
-
- **`stepVisualizer`** (`omdStepVisualizer`): A reference to the associated `omdStepVisualizer` instance.
|
|
25
|
-
- **`simplificationData`** (`object`): The raw data describing the simplification step.
|
|
26
|
-
- **`messages`** (`Array<string>`): Cleaned and extracted messages for each sub-step.
|
|
27
|
-
- **`ruleNames`** (`Array<string>`): Extracted names of the simplification rules applied.
|
|
28
|
-
- **`stepElements`** (`Array<jsvgTextBox>`): An array of `jsvgTextBox` instances, each representing a line of explanation.
|
|
29
|
-
- **`layoutGroup`** (`jsvgLayoutGroup`): The main `jsvgLayoutGroup` that contains all the visual elements of the interactive steps, including the background and individual step messages.
|
|
30
|
-
- **`stepWidth`** (`number`): The fixed width for each step explanation box.
|
|
31
|
-
- **`baseStepHeight`** (`number`): The minimum height for a single step explanation box.
|
|
32
|
-
- **`headerHeight`** (`number`): The height reserved for the header text box.
|
|
33
|
-
- **`fontSize`** (`number`): The base font size for the explanation text.
|
|
34
|
-
- **`smallFontSize`** (`number`): A smaller font size used for secondary text (e.g., step numbers).
|
|
35
|
-
- **`backgroundRect`** (`jsvgRect`): The background rectangle for the entire group of interactive steps.
|
|
36
|
-
- **`contentGroup`** (`jsvgLayoutGroup`): An internal layout group that holds the header and individual step messages.
|
|
37
|
-
- **`onStepHover`** (`Function`): Callback function for hover events on step explanations.
|
|
38
|
-
- **`onStepClick`** (`Function`): Callback function for click events on step explanations.
|
|
39
|
-
|
|
40
|
-
## Public Methods
|
|
41
|
-
|
|
42
|
-
### `setOnStepHover(callback)`
|
|
43
|
-
|
|
44
|
-
Sets a callback function to be executed when the user hovers over a step explanation.
|
|
45
|
-
|
|
46
|
-
- **`callback`** (`Function`): A function that receives `(stepIndex, message, isEntering)` as arguments.
|
|
47
|
-
|
|
48
|
-
### `setOnStepClick(callback)`
|
|
49
|
-
|
|
50
|
-
Sets a callback function to be executed when the user clicks on a step explanation.
|
|
51
|
-
|
|
52
|
-
- **`callback`** (`Function`): A function that receives `(stepIndex, message)` as arguments.
|
|
53
|
-
|
|
54
|
-
### `getLayoutGroup()`
|
|
55
|
-
|
|
56
|
-
Returns the main `jsvgLayoutGroup` containing all the interactive step elements. This group should be added to the parent container (e.g., `omdStepVisualizer`'s `visualContainer`).
|
|
57
|
-
|
|
58
|
-
- **Returns**: `jsvgLayoutGroup`.
|
|
59
|
-
|
|
60
|
-
### `setPosition(x, y)`
|
|
61
|
-
|
|
62
|
-
Sets the position of the entire interactive step group within its parent container.
|
|
63
|
-
|
|
64
|
-
- **`x`** (`number`): The X-coordinate.
|
|
65
|
-
- **`y`** (`number`): The Y-coordinate.
|
|
66
|
-
|
|
67
|
-
### `getDimensions()`
|
|
68
|
-
|
|
69
|
-
Returns the calculated width and height of the interactive step group, including its background.
|
|
70
|
-
|
|
71
|
-
- **Returns**: `object` - An object with `width` and `height` properties.
|
|
72
|
-
|
|
73
|
-
### `destroy()`
|
|
74
|
-
|
|
75
|
-
Cleans up the component by removing all its children, clearing references, and unsetting callbacks.
|
|
76
|
-
|
|
77
|
-
## Internal Methods
|
|
78
|
-
|
|
79
|
-
- **`_extractMessages(data)`**: Extracts and cleans messages from the `simplificationData`, removing HTML tags and bullet points.
|
|
80
|
-
- **`_extractRuleNames(data)`**: Extracts rule names from the `simplificationData`, providing default values if not present.
|
|
81
|
-
- **`setupLayoutGroup()`**: Initializes the main `layoutGroup` and creates its `backgroundRect`, setting initial styling.
|
|
82
|
-
- **`createStepElements()`**: Orchestrates the creation of individual step explanation elements. It decides whether to create a single step element or multiple, based on the number of messages.
|
|
83
|
-
- **`createSingleStepElement(message, index)`**: Creates a header and a single `jsvgTextBox` for a step explanation when there's only one message.
|
|
84
|
-
- **`createMultipleStepElements()`**: Creates a header and multiple `jsvgTextBox` elements for step explanations when there are multiple messages, optionally including step numbers.
|
|
85
|
-
- **`createHeaderBox(headerText)`**: Creates a styled `jsvgTextBox` to serve as a header for the explanation group.
|
|
86
|
-
- **`createStepTextBox(message, index, isMultiple)`**: Creates an individual styled `jsvgTextBox` for a step message, calculates its height, and stores relevant step data.
|
|
87
|
-
- **`formatStepContent(message, index, isMultiple)`**: Formats the raw message content into HTML, adding styling for step numbers, bullets, and highlighting operation details (action, value).
|
|
88
|
-
- **`applyStepStyling(stepBox, content, isMultiple)`**: Applies CSS styling to the `jsvgTextBox`'s underlying DOM element and sets its `innerHTML` with the formatted content.
|
|
89
|
-
- **`setupStepInteractions(stepBox)`**: Sets up `mouseenter`, `mouseleave`, and `click` event listeners for a step box, triggering hover and click callbacks.
|
|
90
|
-
- **`calculateStepHeight(message)`**: Dynamically calculates the required height for a step box based on its content, using a temporary DOM element for accurate measurement.
|
|
91
|
-
- **`updateBackgroundSize()`**: Adjusts the size of the `backgroundRect` to fit the dynamically calculated content height and width.
|
|
92
|
-
- **`isOperationMessage(message)`**: Checks if a message string indicates an operation (e.g., "Added X to both sides").
|
|
93
|
-
- **`extractOperationAction(message)`**: Extracts the action verb (e.g., "Added", "Subtracted") from an operation message.
|
|
94
|
-
- **`extractOperationValue(message)`**: Extracts the value (e.g., "3", "x") from an operation message.
|
|
95
|
-
- **`extractOperationValueNode(message)`**: Attempts to extract the `omdNode` representing the value from an operation message, if available in the `simplificationData`.
|
|
96
|
-
|
|
97
|
-
## How it Works
|
|
98
|
-
|
|
99
|
-
This class takes simplification data and renders it as a series of interactive text boxes. Each box represents a sub-step or a part of the explanation. It dynamically calculates sizes and positions to ensure the text boxes are readable and visually appealing. Hover and click events on these boxes can be used to trigger further actions, such as highlighting specific nodes in the main equation display.
|
|
100
|
-
|
|
101
|
-
## Example
|
|
102
|
-
|
|
103
|
-
This class is typically used internally by `omdStepVisualizerTextBoxes`.
|
|
104
|
-
|
|
105
|
-
```javascript
|
|
106
|
-
// Example of internal usage within omdStepVisualizerTextBoxes:
|
|
107
|
-
// const interactiveSteps = new omdStepVisualizerInteractiveSteps(this.stepVisualizer, simplificationData);
|
|
108
|
-
// this.stepVisualizer.visualContainer.addChild(interactiveSteps.getLayoutGroup());
|
|
1
|
+
# omdStepVisualizerInteractiveSteps
|
|
2
|
+
|
|
3
|
+
This class creates and manages the interactive text boxes that display detailed explanations for simplification steps within the `omdStepVisualizer`. It formats the messages, handles styling, and sets up hover and click interactions, allowing users to explore the mathematical transformations.
|
|
4
|
+
|
|
5
|
+
## Class Definition
|
|
6
|
+
|
|
7
|
+
```javascript
|
|
8
|
+
export class omdStepVisualizerInteractiveSteps
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Constructor
|
|
12
|
+
|
|
13
|
+
### `new omdStepVisualizerInteractiveSteps(stepVisualizer, simplificationData)`
|
|
14
|
+
|
|
15
|
+
Creates a new `omdStepVisualizerInteractiveSteps` instance.
|
|
16
|
+
|
|
17
|
+
- **`stepVisualizer`** (`omdStepVisualizer`): A reference to the `omdStepVisualizer` instance this component is associated with.
|
|
18
|
+
- **`simplificationData`** (`object`): An object containing the simplification details for the step, typically including `message`, `rawMessages`, `ruleNames`, and potentially `operationValueNode`.
|
|
19
|
+
|
|
20
|
+
During construction, it extracts and cleans messages and rule names from the `simplificationData`, initializes layout properties (like `stepWidth`, `fontSize`), sets up the main `layoutGroup`, and creates the individual step elements.
|
|
21
|
+
|
|
22
|
+
## Public Properties
|
|
23
|
+
|
|
24
|
+
- **`stepVisualizer`** (`omdStepVisualizer`): A reference to the associated `omdStepVisualizer` instance.
|
|
25
|
+
- **`simplificationData`** (`object`): The raw data describing the simplification step.
|
|
26
|
+
- **`messages`** (`Array<string>`): Cleaned and extracted messages for each sub-step.
|
|
27
|
+
- **`ruleNames`** (`Array<string>`): Extracted names of the simplification rules applied.
|
|
28
|
+
- **`stepElements`** (`Array<jsvgTextBox>`): An array of `jsvgTextBox` instances, each representing a line of explanation.
|
|
29
|
+
- **`layoutGroup`** (`jsvgLayoutGroup`): The main `jsvgLayoutGroup` that contains all the visual elements of the interactive steps, including the background and individual step messages.
|
|
30
|
+
- **`stepWidth`** (`number`): The fixed width for each step explanation box.
|
|
31
|
+
- **`baseStepHeight`** (`number`): The minimum height for a single step explanation box.
|
|
32
|
+
- **`headerHeight`** (`number`): The height reserved for the header text box.
|
|
33
|
+
- **`fontSize`** (`number`): The base font size for the explanation text.
|
|
34
|
+
- **`smallFontSize`** (`number`): A smaller font size used for secondary text (e.g., step numbers).
|
|
35
|
+
- **`backgroundRect`** (`jsvgRect`): The background rectangle for the entire group of interactive steps.
|
|
36
|
+
- **`contentGroup`** (`jsvgLayoutGroup`): An internal layout group that holds the header and individual step messages.
|
|
37
|
+
- **`onStepHover`** (`Function`): Callback function for hover events on step explanations.
|
|
38
|
+
- **`onStepClick`** (`Function`): Callback function for click events on step explanations.
|
|
39
|
+
|
|
40
|
+
## Public Methods
|
|
41
|
+
|
|
42
|
+
### `setOnStepHover(callback)`
|
|
43
|
+
|
|
44
|
+
Sets a callback function to be executed when the user hovers over a step explanation.
|
|
45
|
+
|
|
46
|
+
- **`callback`** (`Function`): A function that receives `(stepIndex, message, isEntering)` as arguments.
|
|
47
|
+
|
|
48
|
+
### `setOnStepClick(callback)`
|
|
49
|
+
|
|
50
|
+
Sets a callback function to be executed when the user clicks on a step explanation.
|
|
51
|
+
|
|
52
|
+
- **`callback`** (`Function`): A function that receives `(stepIndex, message)` as arguments.
|
|
53
|
+
|
|
54
|
+
### `getLayoutGroup()`
|
|
55
|
+
|
|
56
|
+
Returns the main `jsvgLayoutGroup` containing all the interactive step elements. This group should be added to the parent container (e.g., `omdStepVisualizer`'s `visualContainer`).
|
|
57
|
+
|
|
58
|
+
- **Returns**: `jsvgLayoutGroup`.
|
|
59
|
+
|
|
60
|
+
### `setPosition(x, y)`
|
|
61
|
+
|
|
62
|
+
Sets the position of the entire interactive step group within its parent container.
|
|
63
|
+
|
|
64
|
+
- **`x`** (`number`): The X-coordinate.
|
|
65
|
+
- **`y`** (`number`): The Y-coordinate.
|
|
66
|
+
|
|
67
|
+
### `getDimensions()`
|
|
68
|
+
|
|
69
|
+
Returns the calculated width and height of the interactive step group, including its background.
|
|
70
|
+
|
|
71
|
+
- **Returns**: `object` - An object with `width` and `height` properties.
|
|
72
|
+
|
|
73
|
+
### `destroy()`
|
|
74
|
+
|
|
75
|
+
Cleans up the component by removing all its children, clearing references, and unsetting callbacks.
|
|
76
|
+
|
|
77
|
+
## Internal Methods
|
|
78
|
+
|
|
79
|
+
- **`_extractMessages(data)`**: Extracts and cleans messages from the `simplificationData`, removing HTML tags and bullet points.
|
|
80
|
+
- **`_extractRuleNames(data)`**: Extracts rule names from the `simplificationData`, providing default values if not present.
|
|
81
|
+
- **`setupLayoutGroup()`**: Initializes the main `layoutGroup` and creates its `backgroundRect`, setting initial styling.
|
|
82
|
+
- **`createStepElements()`**: Orchestrates the creation of individual step explanation elements. It decides whether to create a single step element or multiple, based on the number of messages.
|
|
83
|
+
- **`createSingleStepElement(message, index)`**: Creates a header and a single `jsvgTextBox` for a step explanation when there's only one message.
|
|
84
|
+
- **`createMultipleStepElements()`**: Creates a header and multiple `jsvgTextBox` elements for step explanations when there are multiple messages, optionally including step numbers.
|
|
85
|
+
- **`createHeaderBox(headerText)`**: Creates a styled `jsvgTextBox` to serve as a header for the explanation group.
|
|
86
|
+
- **`createStepTextBox(message, index, isMultiple)`**: Creates an individual styled `jsvgTextBox` for a step message, calculates its height, and stores relevant step data.
|
|
87
|
+
- **`formatStepContent(message, index, isMultiple)`**: Formats the raw message content into HTML, adding styling for step numbers, bullets, and highlighting operation details (action, value).
|
|
88
|
+
- **`applyStepStyling(stepBox, content, isMultiple)`**: Applies CSS styling to the `jsvgTextBox`'s underlying DOM element and sets its `innerHTML` with the formatted content.
|
|
89
|
+
- **`setupStepInteractions(stepBox)`**: Sets up `mouseenter`, `mouseleave`, and `click` event listeners for a step box, triggering hover and click callbacks.
|
|
90
|
+
- **`calculateStepHeight(message)`**: Dynamically calculates the required height for a step box based on its content, using a temporary DOM element for accurate measurement.
|
|
91
|
+
- **`updateBackgroundSize()`**: Adjusts the size of the `backgroundRect` to fit the dynamically calculated content height and width.
|
|
92
|
+
- **`isOperationMessage(message)`**: Checks if a message string indicates an operation (e.g., "Added X to both sides").
|
|
93
|
+
- **`extractOperationAction(message)`**: Extracts the action verb (e.g., "Added", "Subtracted") from an operation message.
|
|
94
|
+
- **`extractOperationValue(message)`**: Extracts the value (e.g., "3", "x") from an operation message.
|
|
95
|
+
- **`extractOperationValueNode(message)`**: Attempts to extract the `omdNode` representing the value from an operation message, if available in the `simplificationData`.
|
|
96
|
+
|
|
97
|
+
## How it Works
|
|
98
|
+
|
|
99
|
+
This class takes simplification data and renders it as a series of interactive text boxes. Each box represents a sub-step or a part of the explanation. It dynamically calculates sizes and positions to ensure the text boxes are readable and visually appealing. Hover and click events on these boxes can be used to trigger further actions, such as highlighting specific nodes in the main equation display.
|
|
100
|
+
|
|
101
|
+
## Example
|
|
102
|
+
|
|
103
|
+
This class is typically used internally by `omdStepVisualizerTextBoxes`.
|
|
104
|
+
|
|
105
|
+
```javascript
|
|
106
|
+
// Example of internal usage within omdStepVisualizerTextBoxes:
|
|
107
|
+
// const interactiveSteps = new omdStepVisualizerInteractiveSteps(this.stepVisualizer, simplificationData);
|
|
108
|
+
// this.stepVisualizer.visualContainer.addChild(interactiveSteps.getLayoutGroup());
|
|
109
109
|
```
|
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
# omdStepVisualizerLayout
|
|
2
|
-
|
|
3
|
-
Manages the visual layout, positioning, and visibility of elements within the `omdStepVisualizer`. It ensures that step dots, connecting lines, and associated text boxes are correctly positioned relative to the mathematical equations, maintaining a clean and interactive display.
|
|
4
|
-
|
|
5
|
-
## Class Definition
|
|
6
|
-
|
|
7
|
-
```javascript
|
|
8
|
-
export class omdStepVisualizerLayout
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Constructor
|
|
12
|
-
|
|
13
|
-
### `new omdStepVisualizerLayout(stepVisualizer)`
|
|
14
|
-
|
|
15
|
-
Creates a new `omdStepVisualizerLayout` instance.
|
|
16
|
-
|
|
17
|
-
- **`stepVisualizer`** (`omdStepVisualizer`): A reference to the `omdStepVisualizer` instance this layout manager will control.
|
|
18
|
-
|
|
19
|
-
## Public Properties
|
|
20
|
-
|
|
21
|
-
- **`stepVisualizer`** (`omdStepVisualizer`): The associated `omdStepVisualizer` instance.
|
|
22
|
-
|
|
23
|
-
## Public Methods
|
|
24
|
-
|
|
25
|
-
### `updateVisualLayout()`
|
|
26
|
-
|
|
27
|
-
Calculates and applies the positions of all visual elements (dots, lines, text boxes) relative to the mathematical equations in the sequence. It ensures proper alignment and spacing, accounting for factors like equation background padding and the dynamic size of text boxes.
|
|
28
|
-
|
|
29
|
-
### `findDotIndexForEquation(equation)`
|
|
30
|
-
|
|
31
|
-
Finds the index of the step dot associated with a given `omdEquationNode` within the `stepVisualizer.stepDots` array.
|
|
32
|
-
|
|
33
|
-
- **`equation`** (`omdEquationNode`): The equation node to find the corresponding dot for.
|
|
34
|
-
- **Returns**: `number` - The 0-based index of the dot, or `-1` if not found.
|
|
35
|
-
|
|
36
|
-
### `updateVisualZOrder()`
|
|
37
|
-
|
|
38
|
-
Manages the z-order (stacking order) of the visual elements to ensure they are rendered correctly. Lines are placed behind dots, and text boxes are placed on top of everything else.
|
|
39
|
-
|
|
40
|
-
### `updateAllLinePositions()`
|
|
41
|
-
|
|
42
|
-
Recalculates and updates the start and end points of all connecting lines between the step dots. This ensures lines accurately connect the centers of the dots, even after layout changes.
|
|
43
|
-
|
|
44
|
-
### `updateVisualVisibility()`
|
|
45
|
-
|
|
46
|
-
Adjusts the visibility of the step dots and lines based on the visibility of their corresponding equations. It also dynamically re-creates line segments only between currently visible dots, ensuring no lines are drawn to hidden steps.
|
|
47
|
-
|
|
48
|
-
### `updateDotClickability(dot)`
|
|
49
|
-
|
|
50
|
-
Enables or disables the click functionality for a specific step dot. It sets the cursor style to `"pointer"` when clickable and `"default"` otherwise, and attaches/detaches the `onclick` event handler.
|
|
51
|
-
|
|
52
|
-
- **`dot`** (`jsvgEllipse`): The `jsvgEllipse` element representing the dot.
|
|
53
|
-
|
|
54
|
-
## Internal Methods
|
|
55
|
-
|
|
56
|
-
- **`_getMaxEquationEffectivePaddingX()`**: Computes the maximum effective horizontal padding (x) among all visible `omdEquationNode` steps. This value is used to offset the visual tracker, preventing overlap with equation backgrounds.
|
|
57
|
-
|
|
58
|
-
## How it Works
|
|
59
|
-
|
|
60
|
-
This class works in conjunction with `omdStepVisualizer` to dynamically arrange the visual components. When the sequence of equations changes (e.g., steps are added or hidden), `omdStepVisualizer` calls methods on this layout manager to re-calculate and apply the new visual arrangement.
|
|
61
|
-
|
|
62
|
-
## Example
|
|
63
|
-
|
|
64
|
-
This class is primarily used internally by `omdStepVisualizer`:
|
|
65
|
-
|
|
66
|
-
```javascript
|
|
67
|
-
// Inside omdStepVisualizer's updateLayout method:
|
|
68
|
-
this.layoutManager.updateVisualLayout();
|
|
69
|
-
this.layoutManager.updateVisualVisibility();
|
|
70
|
-
this.layoutManager.updateAllLinePositions();
|
|
1
|
+
# omdStepVisualizerLayout
|
|
2
|
+
|
|
3
|
+
Manages the visual layout, positioning, and visibility of elements within the `omdStepVisualizer`. It ensures that step dots, connecting lines, and associated text boxes are correctly positioned relative to the mathematical equations, maintaining a clean and interactive display.
|
|
4
|
+
|
|
5
|
+
## Class Definition
|
|
6
|
+
|
|
7
|
+
```javascript
|
|
8
|
+
export class omdStepVisualizerLayout
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Constructor
|
|
12
|
+
|
|
13
|
+
### `new omdStepVisualizerLayout(stepVisualizer)`
|
|
14
|
+
|
|
15
|
+
Creates a new `omdStepVisualizerLayout` instance.
|
|
16
|
+
|
|
17
|
+
- **`stepVisualizer`** (`omdStepVisualizer`): A reference to the `omdStepVisualizer` instance this layout manager will control.
|
|
18
|
+
|
|
19
|
+
## Public Properties
|
|
20
|
+
|
|
21
|
+
- **`stepVisualizer`** (`omdStepVisualizer`): The associated `omdStepVisualizer` instance.
|
|
22
|
+
|
|
23
|
+
## Public Methods
|
|
24
|
+
|
|
25
|
+
### `updateVisualLayout()`
|
|
26
|
+
|
|
27
|
+
Calculates and applies the positions of all visual elements (dots, lines, text boxes) relative to the mathematical equations in the sequence. It ensures proper alignment and spacing, accounting for factors like equation background padding and the dynamic size of text boxes.
|
|
28
|
+
|
|
29
|
+
### `findDotIndexForEquation(equation)`
|
|
30
|
+
|
|
31
|
+
Finds the index of the step dot associated with a given `omdEquationNode` within the `stepVisualizer.stepDots` array.
|
|
32
|
+
|
|
33
|
+
- **`equation`** (`omdEquationNode`): The equation node to find the corresponding dot for.
|
|
34
|
+
- **Returns**: `number` - The 0-based index of the dot, or `-1` if not found.
|
|
35
|
+
|
|
36
|
+
### `updateVisualZOrder()`
|
|
37
|
+
|
|
38
|
+
Manages the z-order (stacking order) of the visual elements to ensure they are rendered correctly. Lines are placed behind dots, and text boxes are placed on top of everything else.
|
|
39
|
+
|
|
40
|
+
### `updateAllLinePositions()`
|
|
41
|
+
|
|
42
|
+
Recalculates and updates the start and end points of all connecting lines between the step dots. This ensures lines accurately connect the centers of the dots, even after layout changes.
|
|
43
|
+
|
|
44
|
+
### `updateVisualVisibility()`
|
|
45
|
+
|
|
46
|
+
Adjusts the visibility of the step dots and lines based on the visibility of their corresponding equations. It also dynamically re-creates line segments only between currently visible dots, ensuring no lines are drawn to hidden steps.
|
|
47
|
+
|
|
48
|
+
### `updateDotClickability(dot)`
|
|
49
|
+
|
|
50
|
+
Enables or disables the click functionality for a specific step dot. It sets the cursor style to `"pointer"` when clickable and `"default"` otherwise, and attaches/detaches the `onclick` event handler.
|
|
51
|
+
|
|
52
|
+
- **`dot`** (`jsvgEllipse`): The `jsvgEllipse` element representing the dot.
|
|
53
|
+
|
|
54
|
+
## Internal Methods
|
|
55
|
+
|
|
56
|
+
- **`_getMaxEquationEffectivePaddingX()`**: Computes the maximum effective horizontal padding (x) among all visible `omdEquationNode` steps. This value is used to offset the visual tracker, preventing overlap with equation backgrounds.
|
|
57
|
+
|
|
58
|
+
## How it Works
|
|
59
|
+
|
|
60
|
+
This class works in conjunction with `omdStepVisualizer` to dynamically arrange the visual components. When the sequence of equations changes (e.g., steps are added or hidden), `omdStepVisualizer` calls methods on this layout manager to re-calculate and apply the new visual arrangement.
|
|
61
|
+
|
|
62
|
+
## Example
|
|
63
|
+
|
|
64
|
+
This class is primarily used internally by `omdStepVisualizer`:
|
|
65
|
+
|
|
66
|
+
```javascript
|
|
67
|
+
// Inside omdStepVisualizer's updateLayout method:
|
|
68
|
+
this.layoutManager.updateVisualLayout();
|
|
69
|
+
this.layoutManager.updateVisualVisibility();
|
|
70
|
+
this.layoutManager.updateAllLinePositions();
|
|
71
71
|
```
|
|
@@ -1,77 +1,77 @@
|
|
|
1
|
-
# omdStepVisualizerTextBoxes
|
|
2
|
-
|
|
3
|
-
Manages the interactive text boxes that appear when a step dot is clicked in the `omdStepVisualizer`. This class handles the creation, positioning, and removal of these explanation popups, and integrates with highlighting and layout managers for a cohesive user experience.
|
|
4
|
-
|
|
5
|
-
## Class Definition
|
|
6
|
-
|
|
7
|
-
```javascript
|
|
8
|
-
export class omdStepVisualizerTextBoxes
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Constructor
|
|
12
|
-
|
|
13
|
-
### `new omdStepVisualizerTextBoxes(stepVisualizer, highlighting)`
|
|
14
|
-
|
|
15
|
-
Creates a new `omdStepVisualizerTextBoxes` instance.
|
|
16
|
-
|
|
17
|
-
- **`stepVisualizer`** (`omdStepVisualizer`): A reference to the `omdStepVisualizer` instance.
|
|
18
|
-
- **`highlighting`** (`omdStepVisualizerHighlighting`): A reference to the highlighting manager.
|
|
19
|
-
|
|
20
|
-
During construction, it initializes the `stepTextBoxes` array, which will store references to active text boxes.
|
|
21
|
-
|
|
22
|
-
## Public Properties
|
|
23
|
-
|
|
24
|
-
- **`stepVisualizer`** (`omdStepVisualizer`): The associated step visualizer instance.
|
|
25
|
-
- **`highlighting`** (`omdStepVisualizerHighlighting`): The associated highlighting instance.
|
|
26
|
-
- **`stepTextBoxes`** (`Array<object>`): An array of objects, each representing an active text box. Each object contains `dotIndex`, `interactiveSteps` (the `omdStepVisualizerInteractiveSteps` instance), and `layoutGroup` (its `jsvgLayoutGroup`).
|
|
27
|
-
|
|
28
|
-
## Public Methods
|
|
29
|
-
|
|
30
|
-
### `createTextBoxForDot(dotIndex)`
|
|
31
|
-
|
|
32
|
-
Creates and displays an interactive text box for the specified step dot. This involves retrieving simplification data, finding the appropriate positioning reference, and then creating and adding the `omdStepVisualizerInteractiveSteps` component to the visualizer's container.
|
|
33
|
-
|
|
34
|
-
- **`dotIndex`** (`number`): The index of the dot for which to create the text box.
|
|
35
|
-
|
|
36
|
-
### `removeTextBoxForDot(dotIndex)`
|
|
37
|
-
|
|
38
|
-
Removes the text box associated with the specified step dot. It destroys the `omdStepVisualizerInteractiveSteps` instance and removes its `layoutGroup` from the visual container, then triggers a layout update.
|
|
39
|
-
|
|
40
|
-
- **`dotIndex`** (`number`): The index of the dot whose text box should be removed.
|
|
41
|
-
|
|
42
|
-
### `clearAllTextBoxes()`
|
|
43
|
-
|
|
44
|
-
Removes all active text boxes from the visualizer. It iterates through all tracked text boxes, destroys their `interactiveSteps` instances, removes their `layoutGroup`s from the visual container, and then clears the `stepTextBoxes` array. A layout update is triggered afterwards.
|
|
45
|
-
|
|
46
|
-
### `getStepTextBoxes()`
|
|
47
|
-
|
|
48
|
-
Returns an array of all currently active text box objects managed by this class.
|
|
49
|
-
|
|
50
|
-
- **Returns**: `Array<object>`.
|
|
51
|
-
|
|
52
|
-
## Internal Methods
|
|
53
|
-
|
|
54
|
-
- **`_createInteractiveStepsForDot(dotIndex, targetDot, simplificationData)`**: Creates and configures an `omdStepVisualizerInteractiveSteps` instance. It positions the text box relative to the `targetDot`, sets up hover and click interactions, and adds the text box's `layoutGroup` to the `stepVisualizer.visualContainer`.
|
|
55
|
-
- **`_findDotAboveForPositioning(dotIndex)`**: Determines the appropriate `omdEquationNode` (and its corresponding dot) to position the text box relative to. It searches for the nearest visible equation above the clicked dot, falling back to the clicked dot itself if no such equation is found.
|
|
56
|
-
- **`_getSimplificationDataForDot(dotIndex)`**: Retrieves the simplification data for a given dot by delegating the call to the `stepVisualizer`'s internal method (`stepVisualizer._getSimplificationDataForDot`).
|
|
57
|
-
|
|
58
|
-
## How it Works
|
|
59
|
-
|
|
60
|
-
When a user clicks a step dot in the `omdStepVisualizer`, this class:
|
|
61
|
-
|
|
62
|
-
1. **Fetches Data**: Requests simplification data from the step visualizer for the clicked step.
|
|
63
|
-
2. **Creates UI**: Instantiates an `omdStepVisualizerInteractiveSteps` component, which renders the explanation text and interactive elements.
|
|
64
|
-
3. **Positions**: Calculates the optimal position for the text box, usually to the right of the step dot, and ensures it doesn't overlap with other elements.
|
|
65
|
-
4. **Highlighting Integration**: Works with `omdStepVisualizerHighlighting` to trigger visual feedback when the text box is displayed or interacted with.
|
|
66
|
-
|
|
67
|
-
## Example
|
|
68
|
-
|
|
69
|
-
This class is primarily used internally by `omdStepVisualizer`:
|
|
70
|
-
|
|
71
|
-
```javascript
|
|
72
|
-
// Inside omdStepVisualizer's _handleDotClick method:
|
|
73
|
-
this.textBoxManager.createTextBoxForDot(dotIndex);
|
|
74
|
-
|
|
75
|
-
// Inside omdStepVisualizer's _clearActiveDot method:
|
|
76
|
-
this.textBoxManager.removeTextBoxForDot(this.activeDotIndex);
|
|
1
|
+
# omdStepVisualizerTextBoxes
|
|
2
|
+
|
|
3
|
+
Manages the interactive text boxes that appear when a step dot is clicked in the `omdStepVisualizer`. This class handles the creation, positioning, and removal of these explanation popups, and integrates with highlighting and layout managers for a cohesive user experience.
|
|
4
|
+
|
|
5
|
+
## Class Definition
|
|
6
|
+
|
|
7
|
+
```javascript
|
|
8
|
+
export class omdStepVisualizerTextBoxes
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Constructor
|
|
12
|
+
|
|
13
|
+
### `new omdStepVisualizerTextBoxes(stepVisualizer, highlighting)`
|
|
14
|
+
|
|
15
|
+
Creates a new `omdStepVisualizerTextBoxes` instance.
|
|
16
|
+
|
|
17
|
+
- **`stepVisualizer`** (`omdStepVisualizer`): A reference to the `omdStepVisualizer` instance.
|
|
18
|
+
- **`highlighting`** (`omdStepVisualizerHighlighting`): A reference to the highlighting manager.
|
|
19
|
+
|
|
20
|
+
During construction, it initializes the `stepTextBoxes` array, which will store references to active text boxes.
|
|
21
|
+
|
|
22
|
+
## Public Properties
|
|
23
|
+
|
|
24
|
+
- **`stepVisualizer`** (`omdStepVisualizer`): The associated step visualizer instance.
|
|
25
|
+
- **`highlighting`** (`omdStepVisualizerHighlighting`): The associated highlighting instance.
|
|
26
|
+
- **`stepTextBoxes`** (`Array<object>`): An array of objects, each representing an active text box. Each object contains `dotIndex`, `interactiveSteps` (the `omdStepVisualizerInteractiveSteps` instance), and `layoutGroup` (its `jsvgLayoutGroup`).
|
|
27
|
+
|
|
28
|
+
## Public Methods
|
|
29
|
+
|
|
30
|
+
### `createTextBoxForDot(dotIndex)`
|
|
31
|
+
|
|
32
|
+
Creates and displays an interactive text box for the specified step dot. This involves retrieving simplification data, finding the appropriate positioning reference, and then creating and adding the `omdStepVisualizerInteractiveSteps` component to the visualizer's container.
|
|
33
|
+
|
|
34
|
+
- **`dotIndex`** (`number`): The index of the dot for which to create the text box.
|
|
35
|
+
|
|
36
|
+
### `removeTextBoxForDot(dotIndex)`
|
|
37
|
+
|
|
38
|
+
Removes the text box associated with the specified step dot. It destroys the `omdStepVisualizerInteractiveSteps` instance and removes its `layoutGroup` from the visual container, then triggers a layout update.
|
|
39
|
+
|
|
40
|
+
- **`dotIndex`** (`number`): The index of the dot whose text box should be removed.
|
|
41
|
+
|
|
42
|
+
### `clearAllTextBoxes()`
|
|
43
|
+
|
|
44
|
+
Removes all active text boxes from the visualizer. It iterates through all tracked text boxes, destroys their `interactiveSteps` instances, removes their `layoutGroup`s from the visual container, and then clears the `stepTextBoxes` array. A layout update is triggered afterwards.
|
|
45
|
+
|
|
46
|
+
### `getStepTextBoxes()`
|
|
47
|
+
|
|
48
|
+
Returns an array of all currently active text box objects managed by this class.
|
|
49
|
+
|
|
50
|
+
- **Returns**: `Array<object>`.
|
|
51
|
+
|
|
52
|
+
## Internal Methods
|
|
53
|
+
|
|
54
|
+
- **`_createInteractiveStepsForDot(dotIndex, targetDot, simplificationData)`**: Creates and configures an `omdStepVisualizerInteractiveSteps` instance. It positions the text box relative to the `targetDot`, sets up hover and click interactions, and adds the text box's `layoutGroup` to the `stepVisualizer.visualContainer`.
|
|
55
|
+
- **`_findDotAboveForPositioning(dotIndex)`**: Determines the appropriate `omdEquationNode` (and its corresponding dot) to position the text box relative to. It searches for the nearest visible equation above the clicked dot, falling back to the clicked dot itself if no such equation is found.
|
|
56
|
+
- **`_getSimplificationDataForDot(dotIndex)`**: Retrieves the simplification data for a given dot by delegating the call to the `stepVisualizer`'s internal method (`stepVisualizer._getSimplificationDataForDot`).
|
|
57
|
+
|
|
58
|
+
## How it Works
|
|
59
|
+
|
|
60
|
+
When a user clicks a step dot in the `omdStepVisualizer`, this class:
|
|
61
|
+
|
|
62
|
+
1. **Fetches Data**: Requests simplification data from the step visualizer for the clicked step.
|
|
63
|
+
2. **Creates UI**: Instantiates an `omdStepVisualizerInteractiveSteps` component, which renders the explanation text and interactive elements.
|
|
64
|
+
3. **Positions**: Calculates the optimal position for the text box, usually to the right of the step dot, and ensures it doesn't overlap with other elements.
|
|
65
|
+
4. **Highlighting Integration**: Works with `omdStepVisualizerHighlighting` to trigger visual feedback when the text box is displayed or interacted with.
|
|
66
|
+
|
|
67
|
+
## Example
|
|
68
|
+
|
|
69
|
+
This class is primarily used internally by `omdStepVisualizer`:
|
|
70
|
+
|
|
71
|
+
```javascript
|
|
72
|
+
// Inside omdStepVisualizer's _handleDotClick method:
|
|
73
|
+
this.textBoxManager.createTextBoxForDot(dotIndex);
|
|
74
|
+
|
|
75
|
+
// Inside omdStepVisualizer's _clearActiveDot method:
|
|
76
|
+
this.textBoxManager.removeTextBoxForDot(this.activeDotIndex);
|
|
77
77
|
```
|