native-fn 1.3.1 → 1.3.3
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/native.cjs +95 -25
- package/dist/native.min.cjs +1 -1
- package/dist/native.min.mjs +1 -1
- package/dist/native.mjs +95 -25
- package/dist/native.umd.js +95 -25
- package/dist/native.umd.min.js +1 -1
- package/dist/plugin/dimension/index.cjs +94 -24
- package/dist/plugin/dimension/index.mjs +94 -24
- package/package.json +1 -1
package/dist/native.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var version = "1.3.
|
|
3
|
+
var version = "1.3.3";
|
|
4
4
|
var packageJSON = {
|
|
5
5
|
version: version};
|
|
6
6
|
|
|
@@ -1612,8 +1612,8 @@ function createViewportSegmentObserver() {
|
|
|
1612
1612
|
segments = viewport.segments;
|
|
1613
1613
|
else
|
|
1614
1614
|
segments = visualViewport.segments;
|
|
1615
|
-
if (segments === null || typeof segments === 'undefined')
|
|
1616
|
-
return [];
|
|
1615
|
+
if (segments === null || typeof segments === 'undefined' || segments.length === 0)
|
|
1616
|
+
return [buildFullViewportSegment()];
|
|
1617
1617
|
var results = [];
|
|
1618
1618
|
for (var i = 0; i < segments.length; i++) {
|
|
1619
1619
|
var segment = segments[i];
|
|
@@ -1730,31 +1730,101 @@ function createViewportSegmentObserver() {
|
|
|
1730
1730
|
}
|
|
1731
1731
|
function createVirtualKeyboardObserver() {
|
|
1732
1732
|
var onChangeSubscriptionManager = createSubscriptionManager(attachOnChange, detachOnChange);
|
|
1733
|
+
var virtualKeyboard = globalThis.navigator.virtualKeyboard;
|
|
1734
|
+
var pendingRaf = null;
|
|
1735
|
+
var pendingStabilize = null;
|
|
1736
|
+
var stableInnerHeight = globalThis.innerHeight;
|
|
1737
|
+
var stableInnerWidth = globalThis.innerWidth;
|
|
1733
1738
|
function attachOnChange() {
|
|
1734
|
-
EventListener.add(
|
|
1739
|
+
EventListener.add(virtualKeyboard, { type: 'geometrychange', callback: onGeometryChange, options: { passive: true } });
|
|
1740
|
+
EventListener.add(globalThis, { type: 'resize', callback: onResize, options: { passive: true } });
|
|
1735
1741
|
}
|
|
1736
1742
|
function detachOnChange() {
|
|
1737
|
-
EventListener.remove(
|
|
1743
|
+
EventListener.remove(virtualKeyboard, { type: 'geometrychange', callback: onGeometryChange, options: { passive: true } });
|
|
1744
|
+
EventListener.remove(globalThis, { type: 'resize', callback: onResize, options: { passive: true } });
|
|
1745
|
+
if (pendingRaf !== null) {
|
|
1746
|
+
globalThis.cancelAnimationFrame(pendingRaf);
|
|
1747
|
+
pendingRaf = null;
|
|
1748
|
+
}
|
|
1749
|
+
if (pendingStabilize !== null) {
|
|
1750
|
+
globalThis.clearTimeout(pendingStabilize);
|
|
1751
|
+
pendingStabilize = null;
|
|
1752
|
+
}
|
|
1753
|
+
}
|
|
1754
|
+
function emitAfterFrame() {
|
|
1755
|
+
if (pendingRaf !== null)
|
|
1756
|
+
globalThis.cancelAnimationFrame(pendingRaf);
|
|
1757
|
+
if (typeof globalThis.requestAnimationFrame === 'function') {
|
|
1758
|
+
pendingRaf = globalThis.requestAnimationFrame(function () {
|
|
1759
|
+
pendingRaf = null;
|
|
1760
|
+
onChangeSubscriptionManager.emit(getValue());
|
|
1761
|
+
});
|
|
1762
|
+
}
|
|
1763
|
+
else {
|
|
1764
|
+
defer(function () {
|
|
1765
|
+
onChangeSubscriptionManager.emit(getValue());
|
|
1766
|
+
});
|
|
1767
|
+
}
|
|
1738
1768
|
}
|
|
1739
1769
|
function onGeometryChange() {
|
|
1740
|
-
|
|
1770
|
+
var rect = virtualKeyboard.boundingRect;
|
|
1771
|
+
if (rect.height === 0) {
|
|
1772
|
+
if (pendingStabilize !== null) {
|
|
1773
|
+
globalThis.clearTimeout(pendingStabilize);
|
|
1774
|
+
pendingStabilize = null;
|
|
1775
|
+
}
|
|
1776
|
+
emitAfterFrame();
|
|
1777
|
+
return;
|
|
1778
|
+
}
|
|
1779
|
+
if (pendingStabilize !== null)
|
|
1780
|
+
globalThis.clearTimeout(pendingStabilize);
|
|
1781
|
+
pendingStabilize = globalThis.setTimeout(function () {
|
|
1782
|
+
pendingStabilize = null;
|
|
1783
|
+
emitAfterFrame();
|
|
1784
|
+
}, 100);
|
|
1785
|
+
}
|
|
1786
|
+
function onResize() {
|
|
1787
|
+
var rect = virtualKeyboard.boundingRect;
|
|
1788
|
+
if (rect.height === 0) {
|
|
1789
|
+
stableInnerHeight = globalThis.innerHeight;
|
|
1790
|
+
stableInnerWidth = globalThis.innerWidth;
|
|
1791
|
+
}
|
|
1792
|
+
else {
|
|
1793
|
+
var currentInnerHeight = globalThis.innerHeight;
|
|
1794
|
+
if (rect.y + rect.height > currentInnerHeight)
|
|
1795
|
+
stableInnerHeight = currentInnerHeight - rect.height;
|
|
1796
|
+
else
|
|
1797
|
+
stableInnerHeight = currentInnerHeight;
|
|
1798
|
+
stableInnerWidth = globalThis.innerWidth;
|
|
1799
|
+
}
|
|
1741
1800
|
}
|
|
1742
1801
|
function getValue() {
|
|
1743
|
-
var rect =
|
|
1744
|
-
var left = rect.x;
|
|
1745
|
-
var top = rect.y;
|
|
1802
|
+
var rect = virtualKeyboard.boundingRect;
|
|
1746
1803
|
var width = rect.width;
|
|
1747
1804
|
var height = rect.height;
|
|
1748
|
-
var
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
else
|
|
1757
|
-
|
|
1805
|
+
var top = 0;
|
|
1806
|
+
var bottom = 0;
|
|
1807
|
+
var left = 0;
|
|
1808
|
+
var right = 0;
|
|
1809
|
+
if (height === 0) {
|
|
1810
|
+
stableInnerHeight = globalThis.innerHeight;
|
|
1811
|
+
stableInnerWidth = globalThis.innerWidth;
|
|
1812
|
+
}
|
|
1813
|
+
else {
|
|
1814
|
+
var keyboardMidY = rect.y + height / 2;
|
|
1815
|
+
if (keyboardMidY < stableInnerHeight / 2 || rect.y + height > stableInnerHeight) {
|
|
1816
|
+
top = stableInnerHeight - height;
|
|
1817
|
+
bottom = 0;
|
|
1818
|
+
}
|
|
1819
|
+
else {
|
|
1820
|
+
top = rect.y;
|
|
1821
|
+
bottom = Math.max(0, stableInnerHeight - (rect.y + height));
|
|
1822
|
+
}
|
|
1823
|
+
}
|
|
1824
|
+
if (width > 0) {
|
|
1825
|
+
left = Math.max(0, rect.x);
|
|
1826
|
+
right = Math.max(0, stableInnerWidth - (rect.x + width));
|
|
1827
|
+
}
|
|
1758
1828
|
return {
|
|
1759
1829
|
top: top,
|
|
1760
1830
|
right: right,
|
|
@@ -2227,26 +2297,26 @@ function screenOrientationSupported() {
|
|
|
2227
2297
|
}
|
|
2228
2298
|
function attachOnScreenOrientationChange() {
|
|
2229
2299
|
if (typeof globalThis.screen !== 'undefined' && typeof globalThis.screen.orientation !== 'undefined' && typeof globalThis.screen.orientation.addEventListener === 'function')
|
|
2230
|
-
EventListener.add(globalThis.screen.orientation, {
|
|
2300
|
+
return EventListener.add(globalThis.screen.orientation, {
|
|
2231
2301
|
type: 'change',
|
|
2232
2302
|
callback: onScreenOrientationChange
|
|
2233
2303
|
});
|
|
2234
2304
|
else if (typeof globalThis.orientation !== 'undefined')
|
|
2235
|
-
EventListener.add(globalThis, { type: 'orientationchange', callback: onScreenOrientationChange });
|
|
2305
|
+
return EventListener.add(globalThis, { type: 'orientationchange', callback: onScreenOrientationChange });
|
|
2236
2306
|
else if (ORIENTATION_MEDIA_QUERY_LIST.media !== 'not all')
|
|
2237
|
-
EventListener.add(ORIENTATION_MEDIA_QUERY_LIST, { type: 'change', callback: onScreenOrientationChange });
|
|
2307
|
+
return EventListener.add(ORIENTATION_MEDIA_QUERY_LIST, { type: 'change', callback: onScreenOrientationChange });
|
|
2238
2308
|
throw new NotSupportedError('\'screen.orientation\', \'window.orientation\', and the orientation media query are all unsupported');
|
|
2239
2309
|
}
|
|
2240
2310
|
function detachOnScreenOrientationChange() {
|
|
2241
2311
|
if (typeof globalThis.screen !== 'undefined' && typeof globalThis.screen.orientation !== 'undefined' && typeof globalThis.screen.orientation.removeEventListener === 'function')
|
|
2242
|
-
EventListener.remove(globalThis.screen.orientation, {
|
|
2312
|
+
return EventListener.remove(globalThis.screen.orientation, {
|
|
2243
2313
|
type: 'change',
|
|
2244
2314
|
callback: onScreenOrientationChange
|
|
2245
2315
|
});
|
|
2246
2316
|
else if (typeof globalThis.orientation !== 'undefined')
|
|
2247
|
-
EventListener.remove(globalThis, { type: 'orientationchange', callback: onScreenOrientationChange });
|
|
2317
|
+
return EventListener.remove(globalThis, { type: 'orientationchange', callback: onScreenOrientationChange });
|
|
2248
2318
|
else if (ORIENTATION_MEDIA_QUERY_LIST.media !== 'not all')
|
|
2249
|
-
EventListener.remove(ORIENTATION_MEDIA_QUERY_LIST, { type: 'change', callback: onScreenOrientationChange });
|
|
2319
|
+
return EventListener.remove(ORIENTATION_MEDIA_QUERY_LIST, { type: 'change', callback: onScreenOrientationChange });
|
|
2250
2320
|
throw new NotSupportedError('\'screen.orientation\', \'window.orientation\', and the orientation media query are all unsupported');
|
|
2251
2321
|
}
|
|
2252
2322
|
function onScreenOrientationChange() {
|