Skip to content

Commit 577fd31

Browse files
committed
docs: Comprehensive intent-driven JSDoc for TimelineCanvas (#8553)
1 parent 6325763 commit 577fd31

1 file changed

Lines changed: 29 additions & 1 deletion

File tree

apps/portal/view/news/tickets/TimelineCanvas.mjs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
import Canvas from '../../../../../src/component/Canvas.mjs';
22

33
/**
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+
*
414
* @class Portal.view.news.tickets.TimelineCanvas
515
* @extends Neo.component.Canvas
616
*/
@@ -52,7 +62,14 @@ class TimelineCanvas extends Canvas {
5262
}
5363

5464
/**
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+
*
5673
* @param {Boolean} value
5774
* @param {Boolean} oldValue
5875
* @protected
@@ -120,6 +137,17 @@ class TimelineCanvas extends Canvas {
120137
}
121138

122139
/**
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+
*
123151
* @param {Object[]|Object} records Array of records or Store load event object {items: [...]}
124152
* @param {Number} [attempt=0]
125153
* @param {Boolean} [isResize=false]

0 commit comments

Comments
 (0)