@blorkfield/overlay-core 0.11.3 → 0.11.4
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/README.md +1 -0
- package/dist/index.cjs +20 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -555,6 +555,7 @@ const scene = new OverlayScene(canvas, {
|
|
|
555
555
|
| `floorConfig.minIntegrity` | none | Minimum segments required, otherwise all collapse |
|
|
556
556
|
| `floorConfig.segmentWidths` | none | Proportional widths for each segment (array that sums to 1.0) |
|
|
557
557
|
| `despawnBelowFloor` | 1.0 | Distance below floor to despawn objects (as fraction of height) |
|
|
558
|
+
| `rescaleOnResize` | false | Translate all objects to stay centred when canvas dimensions change — useful for phone rotation and responsive layouts |
|
|
558
559
|
|
|
559
560
|
### Background Configuration
|
|
560
561
|
|
package/dist/index.cjs
CHANGED
|
@@ -2306,6 +2306,26 @@ var OverlayScene = class {
|
|
|
2306
2306
|
}
|
|
2307
2307
|
}
|
|
2308
2308
|
resize(width, height) {
|
|
2309
|
+
if (this.config.rescaleOnResize) {
|
|
2310
|
+
const dx = (width - this.config.bounds.right) / 2;
|
|
2311
|
+
const dy = (height - this.config.bounds.bottom) / 2;
|
|
2312
|
+
for (const entry of this.objects.values()) {
|
|
2313
|
+
const { x, y } = entry.body.position;
|
|
2314
|
+
import_matter_js5.default.Body.setPosition(entry.body, { x: x + dx, y: y + dy });
|
|
2315
|
+
if (entry.originalPosition) {
|
|
2316
|
+
entry.originalPosition = {
|
|
2317
|
+
x: entry.originalPosition.x + dx,
|
|
2318
|
+
y: entry.originalPosition.y + dy
|
|
2319
|
+
};
|
|
2320
|
+
}
|
|
2321
|
+
if (entry.domShadowElement) {
|
|
2322
|
+
const currentLeft = parseFloat(entry.domShadowElement.style.left) || 0;
|
|
2323
|
+
const currentTop = parseFloat(entry.domShadowElement.style.top) || 0;
|
|
2324
|
+
entry.domShadowElement.style.setProperty("left", `${currentLeft + dx}px`, "important");
|
|
2325
|
+
entry.domShadowElement.style.setProperty("top", `${currentTop + dy}px`, "important");
|
|
2326
|
+
}
|
|
2327
|
+
}
|
|
2328
|
+
}
|
|
2309
2329
|
this.canvas.width = width;
|
|
2310
2330
|
this.canvas.height = height;
|
|
2311
2331
|
this.config.bounds = { top: 0, bottom: height, left: 0, right: width };
|