|
1 | 1 | import Canvas from '../../../../../src/component/Canvas.mjs'; |
2 | 2 |
|
3 | 3 | /** |
| 4 | + * @summary The "Coordinator" component for the Neural Timeline, bridging the App Worker and Canvas Worker. |
| 5 | + * |
| 6 | + * This component renders a transparent canvas overlay on top of the Ticket List. It is responsible for: |
| 7 | + * 1. **Data Bridge**: Listening to the `sections` store and passing ticket data to the `TicketCanvas` (SharedWorker). |
| 8 | + * 2. **Visual Alignment**: Calculating the precise DOM positions of Ticket Avatars/Badges to ensure the |
| 9 | + * canvas nodes align perfectly with the HTML content. |
| 10 | + * 3. **Lifecycle Management**: initializing the offscreen canvas transfer and handling resize events. |
| 11 | + * |
| 12 | + * It uses the `Portal.canvas.TicketCanvas` singleton (via Remote Method Access) to drive the actual animation. |
| 13 | + * |
4 | 14 | * @class Portal.view.news.tickets.TimelineCanvas |
5 | 15 | * @extends Neo.component.Canvas |
6 | 16 | */ |
@@ -52,7 +62,14 @@ class TimelineCanvas extends Canvas { |
52 | 62 | } |
53 | 63 |
|
54 | 64 | /** |
55 | | - * Triggered after the offscreenRegistered config got changed |
| 65 | + * Lifecycle hook that runs once the `OffscreenCanvas` has been transferred to the Canvas Worker. |
| 66 | + * |
| 67 | + * This method: |
| 68 | + * 1. Imports the `TicketCanvas` logic into the Canvas Worker context. |
| 69 | + * 2. Initializes the graph in the worker via Remote Method Access (`initGraph`). |
| 70 | + * 3. Sets up a `ResizeObserver` to keep the canvas size synced with the DOM. |
| 71 | + * 4. Triggers the initial data load if store data is available. |
| 72 | + * |
56 | 73 | * @param {Boolean} value |
57 | 74 | * @param {Boolean} oldValue |
58 | 75 | * @protected |
@@ -120,6 +137,17 @@ class TimelineCanvas extends Canvas { |
120 | 137 | } |
121 | 138 |
|
122 | 139 | /** |
| 140 | + * The core "Alignment Engine" of the timeline. |
| 141 | + * |
| 142 | + * This method synchronizes the Canvas nodes with the DOM elements (Avatars/Badges). |
| 143 | + * |
| 144 | + * **Strategy:** |
| 145 | + * 1. **Targeting**: It uses the `-target` ID suffix to find the specific DOM elements (Avatars) within the ticket list. |
| 146 | + * 2. **Measurement**: It fetches the `DOMRect` for every target to get its exact screen position. |
| 147 | + * 3. **Translation**: It converts these screen coordinates into Canvas-local coordinates. |
| 148 | + * 4. **Handoff**: It packages this geometric data (x, y, radius, color) and sends it to the |
| 149 | + * `TicketCanvas` worker to update the physics simulation. |
| 150 | + * |
123 | 151 | * @param {Object[]|Object} records Array of records or Store load event object {items: [...]} |
124 | 152 | * @param {Number} [attempt=0] |
125 | 153 | * @param {Boolean} [isResize=false] |
|
0 commit comments