@folklore/hooks 0.0.58 → 0.0.59
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/cjs.js +13 -10
- package/dist/es.js +13 -10
- package/package.json +2 -2
package/dist/cjs.js
CHANGED
|
@@ -1766,7 +1766,6 @@ function useWindowSize() {
|
|
|
1766
1766
|
return size;
|
|
1767
1767
|
}
|
|
1768
1768
|
|
|
1769
|
-
const hasViewport = typeof window !== 'undefined' && (window.visualViewport || null) !== null;
|
|
1770
1769
|
const useVisualViewportSize = () => {
|
|
1771
1770
|
const {
|
|
1772
1771
|
width: windowWidth,
|
|
@@ -1779,22 +1778,26 @@ const useVisualViewportSize = () => {
|
|
|
1779
1778
|
width: windowWidth,
|
|
1780
1779
|
height: windowHeight
|
|
1781
1780
|
});
|
|
1782
|
-
const onResize = react.useCallback(e => {
|
|
1783
|
-
const viewport = e.target;
|
|
1784
|
-
setViewportSize({
|
|
1785
|
-
width: viewport.width,
|
|
1786
|
-
height: viewport.height
|
|
1787
|
-
});
|
|
1788
|
-
}, [setViewportSize]);
|
|
1789
1781
|
react.useEffect(() => {
|
|
1790
|
-
if (!
|
|
1782
|
+
if (!typeof window !== 'undefined' && (window.visualViewport || null) !== null) {
|
|
1791
1783
|
return () => {};
|
|
1792
1784
|
}
|
|
1785
|
+
function onResize(e) {
|
|
1786
|
+
const viewport = e.target;
|
|
1787
|
+
setViewportSize({
|
|
1788
|
+
width: viewport.width,
|
|
1789
|
+
height: viewport.height
|
|
1790
|
+
});
|
|
1791
|
+
}
|
|
1792
|
+
setViewportSize({
|
|
1793
|
+
width: window.visualViewport.width,
|
|
1794
|
+
height: window.visualViewport.height
|
|
1795
|
+
});
|
|
1793
1796
|
window.visualViewport.addEventListener('resize', onResize);
|
|
1794
1797
|
return () => {
|
|
1795
1798
|
window.visualViewport.removeEventListener('resize', onResize);
|
|
1796
1799
|
};
|
|
1797
|
-
}, [
|
|
1800
|
+
}, [setViewportSize]);
|
|
1798
1801
|
return {
|
|
1799
1802
|
width: viewportWidth || windowWidth,
|
|
1800
1803
|
height: viewportHeight || windowHeight
|
package/dist/es.js
CHANGED
|
@@ -1755,7 +1755,6 @@ function useWindowSize() {
|
|
|
1755
1755
|
return size;
|
|
1756
1756
|
}
|
|
1757
1757
|
|
|
1758
|
-
const hasViewport = typeof window !== 'undefined' && (window.visualViewport || null) !== null;
|
|
1759
1758
|
const useVisualViewportSize = () => {
|
|
1760
1759
|
const {
|
|
1761
1760
|
width: windowWidth,
|
|
@@ -1768,22 +1767,26 @@ const useVisualViewportSize = () => {
|
|
|
1768
1767
|
width: windowWidth,
|
|
1769
1768
|
height: windowHeight
|
|
1770
1769
|
});
|
|
1771
|
-
const onResize = useCallback(e => {
|
|
1772
|
-
const viewport = e.target;
|
|
1773
|
-
setViewportSize({
|
|
1774
|
-
width: viewport.width,
|
|
1775
|
-
height: viewport.height
|
|
1776
|
-
});
|
|
1777
|
-
}, [setViewportSize]);
|
|
1778
1770
|
useEffect(() => {
|
|
1779
|
-
if (!
|
|
1771
|
+
if (!typeof window !== 'undefined' && (window.visualViewport || null) !== null) {
|
|
1780
1772
|
return () => {};
|
|
1781
1773
|
}
|
|
1774
|
+
function onResize(e) {
|
|
1775
|
+
const viewport = e.target;
|
|
1776
|
+
setViewportSize({
|
|
1777
|
+
width: viewport.width,
|
|
1778
|
+
height: viewport.height
|
|
1779
|
+
});
|
|
1780
|
+
}
|
|
1781
|
+
setViewportSize({
|
|
1782
|
+
width: window.visualViewport.width,
|
|
1783
|
+
height: window.visualViewport.height
|
|
1784
|
+
});
|
|
1782
1785
|
window.visualViewport.addEventListener('resize', onResize);
|
|
1783
1786
|
return () => {
|
|
1784
1787
|
window.visualViewport.removeEventListener('resize', onResize);
|
|
1785
1788
|
};
|
|
1786
|
-
}, [
|
|
1789
|
+
}, [setViewportSize]);
|
|
1787
1790
|
return {
|
|
1788
1791
|
width: viewportWidth || windowWidth,
|
|
1789
1792
|
height: viewportHeight || windowHeight
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@folklore/hooks",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.59",
|
|
4
4
|
"description": "React hooks",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"javascript",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"publishConfig": {
|
|
50
50
|
"access": "public"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "c054f8aebebb312df15dbd87158516bbc750855f",
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"@folklore/events": "^0.0.5",
|
|
55
55
|
"@folklore/services": "^0.1.40",
|