@jsenv/dom 0.14.6 → 0.14.7

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.
Files changed (2) hide show
  1. package/dist/jsenv_dom.js +48 -20
  2. package/package.json +1 -1
package/dist/jsenv_dom.js CHANGED
@@ -11348,26 +11348,6 @@ const visibleRectEffect = (
11348
11348
  });
11349
11349
  }
11350
11350
  }
11351
- {
11352
- // visualViewport resize fires when the virtual keyboard opens/closes on mobile.
11353
- // window resize catches cases visualViewport misses, notably the browser input
11354
- // accessory bar (password/autocomplete suggestions) on iOS Safari which changes
11355
- // the available height without always firing a visualViewport resize event.
11356
- // We listen to both simultaneously; the check is idempotent so duplicates are harmless.
11357
- const onResize = (e) => {
11358
- autoCheck(e);
11359
- };
11360
- if (window.visualViewport) {
11361
- window.visualViewport.addEventListener("resize", onResize);
11362
- addTeardown(() => {
11363
- window.visualViewport.removeEventListener("resize", onResize);
11364
- });
11365
- }
11366
- window.addEventListener("resize", onResize);
11367
- addTeardown(() => {
11368
- window.removeEventListener("resize", onResize);
11369
- });
11370
- }
11371
11351
  {
11372
11352
  // visualViewport scroll fires when the visual viewport pans independently
11373
11353
  // of the layout viewport (e.g. during pinch-zoom). This is distinct from
@@ -11388,6 +11368,42 @@ const visibleRectEffect = (
11388
11368
  });
11389
11369
  }
11390
11370
  }
11371
+ {
11372
+ if (window.visualViewport) {
11373
+ // visualViewport resize fires when the virtual keyboard opens/closes on mobile.
11374
+ // On mobile, tapping from one input to another triggers a resize because
11375
+ // the virtual keyboard briefly starts to close before the new input receives
11376
+ // focus and the keyboard reopens. Debouncing prevents repositioning the
11377
+ // during that transient state, which would cause a visible flicker.
11378
+ let resizeTimeout;
11379
+ const cancelDelayedAutoCheck = () => {
11380
+ clearTimeout(resizeTimeout);
11381
+ };
11382
+ const onVisualViewportResize = (e) => {
11383
+ cancelDelayedAutoCheck();
11384
+ resizeTimeout = setTimeout(() => {
11385
+ autoCheck(e);
11386
+ }, 100);
11387
+ };
11388
+ window.visualViewport.addEventListener(
11389
+ "resize",
11390
+ onVisualViewportResize,
11391
+ );
11392
+ addTeardown(() => {
11393
+ window.visualViewport.removeEventListener(
11394
+ "resize",
11395
+ onVisualViewportResize,
11396
+ );
11397
+ });
11398
+ }
11399
+ const onWindowResize = (e) => {
11400
+ autoCheck(e);
11401
+ };
11402
+ window.addEventListener("resize", onWindowResize);
11403
+ addTeardown(() => {
11404
+ window.removeEventListener("resize", onWindowResize);
11405
+ });
11406
+ }
11391
11407
  on_element_resize: {
11392
11408
  if (skipElementResize) {
11393
11409
  break on_element_resize;
@@ -11529,8 +11545,20 @@ const visibleRectEffect = (
11529
11545
  }
11530
11546
  };
11531
11547
  ancestor.addEventListener("toggle", onToggle);
11548
+
11549
+ const onNaviPositionUpdate = (e) => {
11550
+ autoCheck(e);
11551
+ };
11552
+ ancestor.addEventListener(
11553
+ "navi_position_update",
11554
+ onNaviPositionUpdate,
11555
+ );
11532
11556
  addTeardown(() => {
11533
11557
  ancestor.removeEventListener("toggle", onToggle);
11558
+ ancestor.removeEventListener(
11559
+ "navi_position_update",
11560
+ onNaviPositionUpdate,
11561
+ );
11534
11562
  });
11535
11563
  }
11536
11564
  current = current.parentElement;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/dom",
3
- "version": "0.14.6",
3
+ "version": "0.14.7",
4
4
  "type": "module",
5
5
  "description": "DOM utilities for writing frontend code",
6
6
  "repository": {