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