minimojs 1.0.0-alpha.14 → 1.0.0-alpha.15

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.
@@ -3,6 +3,7 @@ export class CanvasSystem {
3
3
  constructor(canvas) {
4
4
  this.canvas = canvas;
5
5
  this.onResize = () => this.applyResponsiveCanvasLayout();
6
+ this.onViewportChange = () => this.applyResponsiveCanvasLayout();
6
7
  }
7
8
  initialize() {
8
9
  const mountCanvas = () => {
@@ -18,17 +19,27 @@ export class CanvasSystem {
18
19
  window.addEventListener("DOMContentLoaded", mountCanvas, { once: true });
19
20
  }
20
21
  window.addEventListener("resize", this.onResize);
22
+ window.visualViewport?.addEventListener("resize", this.onViewportChange);
23
+ window.visualViewport?.addEventListener("scroll", this.onViewportChange);
21
24
  }
22
25
  applyResponsiveCanvasLayout() {
23
26
  if (!document.body)
24
27
  return;
28
+ const viewportW = Math.max(1, Math.floor(window.visualViewport?.width ??
29
+ window.innerWidth ??
30
+ document.documentElement.clientWidth ??
31
+ 1));
32
+ const viewportH = Math.max(1, Math.floor(window.visualViewport?.height ??
33
+ window.innerHeight ??
34
+ document.documentElement.clientHeight ??
35
+ 1));
25
36
  document.body.style.margin = "0";
26
- document.body.style.minHeight = "100vh";
37
+ document.body.style.height = `${viewportH}px`;
38
+ document.body.style.minHeight = `${viewportH}px`;
27
39
  document.body.style.display = "grid";
28
40
  document.body.style.placeItems = "center";
29
41
  document.body.style.touchAction = "manipulation";
30
- const viewportW = Math.max(1, window.innerWidth);
31
- const viewportH = Math.max(1, window.innerHeight);
42
+ document.body.style.overflow = "hidden";
32
43
  const scale = Math.min(viewportW / this.canvas.width, viewportH / this.canvas.height);
33
44
  const safeScale = Number.isFinite(scale) && scale > 0 ? scale : 1;
34
45
  this.canvas.style.width = `${Math.floor(this.canvas.width * safeScale)}px`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "minimojs",
3
- "version": "1.0.0-alpha.14",
3
+ "version": "1.0.0-alpha.15",
4
4
  "description": "MinimoJS v1 — ultra-minimal, flat, deterministic 2D web game engine. Emoji-only sprites, rAF loop, TypeScript-first, LLM-friendly.",
5
5
  "type": "module",
6
6
  "main": "dist/minimo.js",