Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR refines the background’s resize handling by always wiring up resize events in the constructor and consolidating conditional redraw/scale logic.
- Adds an unconditional
RESIZEevent listener in the constructor to trigger draw and scale services. - Refactors the per-frame check to a single combined width/height comparison block.
- Updates package versions in both the template’s
package.jsonand the rootpackage.json.
Reviewed Changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| template/src/model/domain/callback/Background.js | Wire up resize listener in ctor; merge redraw/scale checks into one conditional |
| template/package.json | Bump dev dependency versions (eslint, vite, vitest, etc.) |
| package.json | Increment template version from 4.2.1 to 4.2.2 |
Files not reviewed (1)
- template/package-lock.json: Language not supported
Comments suppressed due to low confidence (2)
template/src/model/domain/callback/Background.js:25
- No tests appear to cover the new resize handling logic; consider adding unit tests or integration tests to verify that
backgroundDrawServiceandbackgroundChangeScaleServiceare invoked correctly when the stage is resized.
backgroundDrawService(this);
template/src/model/domain/callback/Background.js:23
- Consider reintroducing a check like
!stage.hasEventListener(Event.RESIZE)before adding the listener to prevent registering duplicate handlers and potential memory leaks.
stage.addEventListener(Event.RESIZE, () =>
| stage.addEventListener(Event.RESIZE, () => | ||
| { | ||
| backgroundDrawService(this); | ||
| backgroundChangeScaleService(this); | ||
| }); |
There was a problem hiding this comment.
Add a null check or guard to ensure stage is defined before calling addEventListener, e.g. if (stage) { ... }, to avoid potential runtime errors.
| stage.addEventListener(Event.RESIZE, () => | |
| { | |
| backgroundDrawService(this); | |
| backgroundChangeScaleService(this); | |
| }); | |
| if (stage) { | |
| stage.addEventListener(Event.RESIZE, () => | |
| { | |
| backgroundDrawService(this); | |
| backgroundChangeScaleService(this); | |
| }); | |
| } |
| backgroundDrawService(this); | ||
| backgroundChangeScaleService(this); |
There was a problem hiding this comment.
Current order calls backgroundDrawService before backgroundChangeScaleService, which may draw at the wrong scale. Swap these calls so scaling happens before drawing.
| backgroundDrawService(this); | |
| backgroundChangeScaleService(this); | |
| backgroundChangeScaleService(this); | |
| backgroundDrawService(this); |
No description provided.