@jsenv/dom 0.17.78 → 0.17.80
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/dist/jsenv_dom.js +42 -12
- package/package.json +1 -1
package/dist/jsenv_dom.js
CHANGED
|
@@ -16673,9 +16673,10 @@ const stickyAsRelativeCoords = (
|
|
|
16673
16673
|
* to do with the field being typed into — the page reflows, fixed bars move,
|
|
16674
16674
|
* and a mobile browser fires that resize transiently as focus goes from one
|
|
16675
16675
|
* input to the next. Overlaying leaves the layout alone and hands over a
|
|
16676
|
-
* number instead.
|
|
16677
|
-
*
|
|
16678
|
-
* viewport
|
|
16676
|
+
* number instead. navi offers it (enableVirtualKeyboardOverlay) rather than
|
|
16677
|
+
* taking it by default: the deal also takes away what the browser does for a
|
|
16678
|
+
* shrinking viewport, and that has to be redone by hand (see navi's
|
|
16679
|
+
* layout/virtual_keyboard.js).
|
|
16679
16680
|
*/
|
|
16680
16681
|
|
|
16681
16682
|
const virtualKeyboard = window.navigator.virtualKeyboard;
|
|
@@ -16718,21 +16719,37 @@ const getVirtualKeyboardOverlayHeight = () => {
|
|
|
16718
16719
|
};
|
|
16719
16720
|
|
|
16720
16721
|
/**
|
|
16721
|
-
* Calls `callback` whenever the keyboard shows, hides or resizes
|
|
16722
|
-
*
|
|
16722
|
+
* Calls `callback` whenever the keyboard shows, hides or resizes — whenever
|
|
16723
|
+
* getVirtualKeyboardOverlayHeight() changes. Returns an unsubscribe function;
|
|
16724
|
+
* a no-op (never calls back) without support.
|
|
16725
|
+
*
|
|
16726
|
+
* On the height alone: Chrome (Android 10 / Chrome 153) also fires
|
|
16727
|
+
* "geometrychange" at an unchanged height while the page is scrolled with the
|
|
16728
|
+
* keyboard up, and a listener acting on those — bringing the focused field
|
|
16729
|
+
* back into view — takes the scroll away from the user. The rest of the rect
|
|
16730
|
+
* says nothing either (see getVirtualKeyboardOverlayHeight for its y).
|
|
16723
16731
|
*
|
|
16724
16732
|
* Undebounced on purpose, unlike window/visualViewport resize
|
|
16725
|
-
* (window_size.js):
|
|
16726
|
-
*
|
|
16727
|
-
*
|
|
16733
|
+
* (window_size.js): filtered on the height, what is left is the keyboard
|
|
16734
|
+
* itself changing, not the layout reacting to it, which is the whole point of
|
|
16735
|
+
* overlaying.
|
|
16728
16736
|
*/
|
|
16729
16737
|
const subscribeVirtualKeyboardGeometryChange = (callback) => {
|
|
16730
16738
|
if (!virtualKeyboard) {
|
|
16731
16739
|
return () => {};
|
|
16732
16740
|
}
|
|
16733
|
-
|
|
16741
|
+
let height = getVirtualKeyboardOverlayHeight();
|
|
16742
|
+
const onGeometryChange = (event) => {
|
|
16743
|
+
const newHeight = getVirtualKeyboardOverlayHeight();
|
|
16744
|
+
if (newHeight === height) {
|
|
16745
|
+
return;
|
|
16746
|
+
}
|
|
16747
|
+
height = newHeight;
|
|
16748
|
+
callback(event);
|
|
16749
|
+
};
|
|
16750
|
+
virtualKeyboard.addEventListener("geometrychange", onGeometryChange);
|
|
16734
16751
|
return () => {
|
|
16735
|
-
virtualKeyboard.removeEventListener("geometrychange",
|
|
16752
|
+
virtualKeyboard.removeEventListener("geometrychange", onGeometryChange);
|
|
16736
16753
|
};
|
|
16737
16754
|
};
|
|
16738
16755
|
|
|
@@ -16840,7 +16857,7 @@ window.addEventListener("resize", (event) => {
|
|
|
16840
16857
|
* and only on browsers with no visualViewport at all.
|
|
16841
16858
|
*
|
|
16842
16859
|
* The keyboard is then subtracted rather than assumed to have already shrunk
|
|
16843
|
-
* the viewport: with `overlaysContent` (virtual_keyboard.js,
|
|
16860
|
+
* the viewport: with `overlaysContent` (virtual_keyboard.js, an app turns it on)
|
|
16844
16861
|
* the viewport stays full height and the keyboard is painted over its bottom.
|
|
16845
16862
|
* Zero everywhere else, the browser having done the subtraction itself.
|
|
16846
16863
|
*/
|
|
@@ -17479,13 +17496,26 @@ const visibleRectEffect = (
|
|
|
17479
17496
|
}
|
|
17480
17497
|
}
|
|
17481
17498
|
{
|
|
17499
|
+
// One check per frame, in the frame's animation callbacks: a touchmove
|
|
17500
|
+
// arrives after the pointermove handlers wrote to the DOM, so checking
|
|
17501
|
+
// synchronously forces a layout inside every move of every drag on the
|
|
17502
|
+
// page (a wheel spun in an open sheet), for a position the frame's own
|
|
17503
|
+
// layout gives for free a moment later, before anything is painted.
|
|
17504
|
+
let touchMoveRafId = null;
|
|
17482
17505
|
const onWindowTouchMove = (e) => {
|
|
17483
|
-
|
|
17506
|
+
if (touchMoveRafId !== null) {
|
|
17507
|
+
return;
|
|
17508
|
+
}
|
|
17509
|
+
touchMoveRafId = requestAnimationFrame(() => {
|
|
17510
|
+
touchMoveRafId = null;
|
|
17511
|
+
autoCheck(e);
|
|
17512
|
+
});
|
|
17484
17513
|
};
|
|
17485
17514
|
window.addEventListener("touchmove", onWindowTouchMove, {
|
|
17486
17515
|
passive: true,
|
|
17487
17516
|
});
|
|
17488
17517
|
addTeardown(() => {
|
|
17518
|
+
cancelAnimationFrame(touchMoveRafId);
|
|
17489
17519
|
window.removeEventListener("touchmove", onWindowTouchMove, {
|
|
17490
17520
|
passive: true,
|
|
17491
17521
|
});
|