react-viewport-height 1.1.1 → 1.2.0
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/README.md +0 -1
- package/index.d.ts +18 -0
- package/lib/index.js +1 -0
- package/package.json +64 -61
- package/CHANGELOG.md +0 -15
- package/dist/index.js +0 -2
- package/dist/index.js.map +0 -1
- package/dist/index.modern.js +0 -2
- package/dist/index.modern.js.map +0 -1
- package/dist/index.module.js +0 -2
- package/dist/index.module.js.map +0 -1
- package/dist/index.umd.js +0 -2
- package/dist/index.umd.js.map +0 -1
- package/dist/src/src/index.d.ts +0 -1
- package/dist/src/src/useVH.d.ts +0 -2
- package/dist/src/stories/Demo.d.ts +0 -4
- package/dist/src/stories/Demo.stories.d.ts +0 -4
- package/dist/src/tests/useVH.test.d.ts +0 -1
package/README.md
CHANGED
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
[](https://github.com/dimazuien/react-viewport-height/stargazers)
|
|
9
9
|

|
|
10
10
|

|
|
11
|
-
[](https://dimazuien.github.io/react-viewport-height)
|
|
12
11
|
|
|
13
12
|
A utility for React to set 100vh equal to the actual browser inner window height.
|
|
14
13
|
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
declare module 'react-viewport-height/src/index' {
|
|
2
|
+
import useVH from 'react-viewport-height/src/useVH';
|
|
3
|
+
export default useVH;
|
|
4
|
+
|
|
5
|
+
}
|
|
6
|
+
declare module 'react-viewport-height/src/useVH' {
|
|
7
|
+
const useVH: () => number;
|
|
8
|
+
export default useVH;
|
|
9
|
+
|
|
10
|
+
}
|
|
11
|
+
declare module 'react-viewport-height/tests/useVH.test' {
|
|
12
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
13
|
+
|
|
14
|
+
}
|
|
15
|
+
declare module 'react-viewport-height' {
|
|
16
|
+
import main = require('react-viewport-height/src/index');
|
|
17
|
+
export = main;
|
|
18
|
+
}
|
package/lib/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["react-viewport-height"]=t():e["react-viewport-height"]=t()}(self,(function(){return function(){"use strict";var e={d:function(t,r){for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{default:function(){return a}});var r=require("react");function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var o="--vh",i=function(){return"undefined"!=typeof window?Number((.01*window.innerHeight).toFixed(2)):0},u=0,a=function(){var e,t,a=(e=(0,r.useState)(i()),t=2,function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i=[],u=!0,a=!1;try{for(r=r.call(e);!(u=(n=r.next()).done)&&(i.push(n.value),!t||i.length!==t);u=!0);}catch(e){a=!0,o=e}finally{try{u||null==r.return||r.return()}finally{if(a)throw o}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return n(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),c=a[0],f=a[1],l=(0,r.useCallback)((function(){var e=i();document.documentElement.style.setProperty(o,"".concat(e,"px")),f(e)}),[f]);return(0,r.useLayoutEffect)((function(){return u+=1,l(),window.addEventListener("resize",l),function(){window.removeEventListener("resize",l),0==(u-=1)&&document.documentElement.style.removeProperty(o)}}),[l]),c};return t}()}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-viewport-height",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "A utility for React to set 100vh equal to the actual browser inner window height.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -28,76 +28,79 @@
|
|
|
28
28
|
"url": "https://github.com/dimazuien/react-viewport-height/issues"
|
|
29
29
|
},
|
|
30
30
|
"source": "src/index.ts",
|
|
31
|
-
"main": "
|
|
32
|
-
"
|
|
33
|
-
"module": "dist/index.module.js",
|
|
34
|
-
"unpkg": "dist/index.umd.js",
|
|
35
|
-
"types": "dist/src/index.d.ts",
|
|
36
|
-
"typings": "dist/src/index.d.ts",
|
|
31
|
+
"main": "lib/index.js",
|
|
32
|
+
"typings": "index.d.ts",
|
|
37
33
|
"files": [
|
|
38
|
-
"
|
|
34
|
+
"lib",
|
|
35
|
+
"index.d.ts"
|
|
39
36
|
],
|
|
40
37
|
"sideEffects": false,
|
|
41
38
|
"scripts": {
|
|
42
|
-
"
|
|
39
|
+
"_postinstall": "husky install",
|
|
40
|
+
"build": "webpack",
|
|
41
|
+
"dts": "npx npm-dts generate -e src/index",
|
|
42
|
+
"lint": "eslint .",
|
|
43
43
|
"test": "jest",
|
|
44
|
-
"
|
|
44
|
+
"prepublishOnly": "pinst --disable",
|
|
45
45
|
"release": "semantic-release",
|
|
46
|
-
"
|
|
47
|
-
"storybook:build": "build-storybook",
|
|
48
|
-
"storybook:upload": "gh-pages -d storybook-static --git \"$(which git)\""
|
|
46
|
+
"postpublish": "pinst --enable"
|
|
49
47
|
},
|
|
50
|
-
"dependencies": {},
|
|
51
48
|
"devDependencies": {
|
|
52
|
-
"@babel/core": "7.
|
|
53
|
-
"@
|
|
54
|
-
"@
|
|
55
|
-
"@
|
|
56
|
-
"@
|
|
57
|
-
"@
|
|
58
|
-
"@semantic-release/
|
|
59
|
-
"@semantic-release/
|
|
60
|
-
"@semantic-release/
|
|
61
|
-
"@
|
|
62
|
-
"@
|
|
63
|
-
"@
|
|
64
|
-
"@testing-library/
|
|
65
|
-
"@testing-library/
|
|
66
|
-
"@
|
|
67
|
-
"@
|
|
68
|
-
"@types/
|
|
69
|
-
"@types/react
|
|
70
|
-
"@types/
|
|
71
|
-
"@
|
|
72
|
-
"@
|
|
73
|
-
"
|
|
74
|
-
"
|
|
49
|
+
"@babel/core": "7.17.8",
|
|
50
|
+
"@babel/preset-env": "7.16.11",
|
|
51
|
+
"@babel/preset-react": "7.16.7",
|
|
52
|
+
"@babel/preset-typescript": "7.16.7",
|
|
53
|
+
"@commitlint/cli": "16.2.3",
|
|
54
|
+
"@commitlint/config-conventional": "16.2.1",
|
|
55
|
+
"@semantic-release/changelog": "6.0.1",
|
|
56
|
+
"@semantic-release/commit-analyzer": "9.0.2",
|
|
57
|
+
"@semantic-release/git": "10.0.1",
|
|
58
|
+
"@semantic-release/github": "8.0.4",
|
|
59
|
+
"@semantic-release/npm": "9.0.1",
|
|
60
|
+
"@semantic-release/release-notes-generator": "10.0.3",
|
|
61
|
+
"@testing-library/dom": "8.12.0",
|
|
62
|
+
"@testing-library/jest-dom": "5.16.3",
|
|
63
|
+
"@testing-library/react": "13.0.0",
|
|
64
|
+
"@testing-library/user-event": "14.0.4",
|
|
65
|
+
"@types/jest": "27.4.1",
|
|
66
|
+
"@types/react": "17.0.43",
|
|
67
|
+
"@types/react-dom": "17.0.14",
|
|
68
|
+
"@types/react-router-dom": "5.3.3",
|
|
69
|
+
"@types/testing-library__jest-dom": "5.14.3",
|
|
70
|
+
"@typescript-eslint/eslint-plugin": "5.17.0",
|
|
71
|
+
"@typescript-eslint/parser": "5.17.0",
|
|
72
|
+
"babel-loader": "8.2.4",
|
|
73
|
+
"commitizen": "4.2.4",
|
|
75
74
|
"cz-conventional-changelog": "3.3.0",
|
|
76
|
-
"eslint": "
|
|
77
|
-
"eslint-config-airbnb": "
|
|
78
|
-
"eslint-config-prettier": "
|
|
79
|
-
"eslint-plugin-import": "2.
|
|
80
|
-
"eslint-plugin-jest-dom": "
|
|
81
|
-
"eslint-plugin-jsx-a11y": "6.
|
|
82
|
-
"eslint-plugin-prettier": "
|
|
83
|
-
"eslint-plugin-react": "7.
|
|
84
|
-
"eslint-plugin-react-hooks": "4.
|
|
85
|
-
"eslint-plugin-
|
|
86
|
-
"
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"
|
|
90
|
-
"
|
|
91
|
-
"
|
|
92
|
-
"
|
|
93
|
-
"
|
|
94
|
-
"
|
|
95
|
-
"
|
|
96
|
-
"
|
|
97
|
-
"
|
|
75
|
+
"eslint": "8.12.0",
|
|
76
|
+
"eslint-config-airbnb": "19.0.4",
|
|
77
|
+
"eslint-config-prettier": "8.5.0",
|
|
78
|
+
"eslint-plugin-import": "2.25.4",
|
|
79
|
+
"eslint-plugin-jest-dom": "4.0.1",
|
|
80
|
+
"eslint-plugin-jsx-a11y": "6.5.1",
|
|
81
|
+
"eslint-plugin-prettier": "4.0.0",
|
|
82
|
+
"eslint-plugin-react": "7.29.4",
|
|
83
|
+
"eslint-plugin-react-hooks": "4.4.0",
|
|
84
|
+
"eslint-plugin-simple-import-sort": "7.0.0",
|
|
85
|
+
"eslint-plugin-testing-library": "5.2.0",
|
|
86
|
+
"gh-pages": "3.2.3",
|
|
87
|
+
"husky": "7.0.4",
|
|
88
|
+
"jest": "27.5.1",
|
|
89
|
+
"lint-staged": "12.3.7",
|
|
90
|
+
"npm-dts": "1.3.11",
|
|
91
|
+
"pinst": "3.0.0",
|
|
92
|
+
"prettier": "2.6.2",
|
|
93
|
+
"react": "18.0.0",
|
|
94
|
+
"react-dom": "18.0.0",
|
|
95
|
+
"semantic-release": "19.0.2",
|
|
96
|
+
"ts-jest": "27.1.4",
|
|
97
|
+
"ts-node": "10.7.0",
|
|
98
|
+
"typescript": "4.6.3",
|
|
99
|
+
"webpack": "5.71.0",
|
|
100
|
+
"webpack-cli": "4.9.2"
|
|
98
101
|
},
|
|
99
102
|
"peerDependencies": {
|
|
100
|
-
"react": "^16.8 || ^17",
|
|
101
|
-
"react-dom": "^16.8 || ^17"
|
|
103
|
+
"react": "^16.8 || ^17 || ^18",
|
|
104
|
+
"react-dom": "^16.8 || ^17 || ^18"
|
|
102
105
|
}
|
|
103
106
|
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
## [1.1.1](https://github.com/dimazuien/react-viewport-height/compare/v1.1.0...v1.1.1) (2021-02-22)
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
### Bug Fixes
|
|
5
|
-
|
|
6
|
-
* change typings path ([8587a9a](https://github.com/dimazuien/react-viewport-height/commit/8587a9a84d374daf3c7fd5d43176e6da0596d8ef)), closes [#73](https://github.com/dimazuien/react-viewport-height/issues/73)
|
|
7
|
-
|
|
8
|
-
# [1.1.0](https://github.com/dimazuien/react-viewport-height/compare/v1.0.0...v1.1.0) (2020-12-27)
|
|
9
|
-
|
|
10
|
-
### Features
|
|
11
|
-
|
|
12
|
-
* add ssr check ([8b60760](https://github.com/dimazuien/react-viewport-height/commit/8b60760dd5a6a1c2059a591a2640511d09ab0e0a))
|
|
13
|
-
* remove vh on unmount ([8b60760](https://github.com/dimazuien/react-viewport-height/commit/8b60760dd5a6a1c2059a591a2640511d09ab0e0a))
|
|
14
|
-
* return vh from hook ([8b60760](https://github.com/dimazuien/react-viewport-height/commit/8b60760dd5a6a1c2059a591a2640511d09ab0e0a))
|
|
15
|
-
* make multiple use possible ([8b60760](https://github.com/dimazuien/react-viewport-height/commit/8b60760dd5a6a1c2059a591a2640511d09ab0e0a))
|
package/dist/index.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
var e=require("react"),n=function(){return"undefined"!=typeof window?Number((.01*window.innerHeight).toFixed(2)):0},t=0;module.exports=function(){var r=e.useState(n()),o=r[0],u=r[1],i=e.useCallback(function(){var e=n();document.documentElement.style.setProperty("--vh",e+"px"),u(e)},[u]);return e.useEffect(function(){return t+=1,i(),window.addEventListener("resize",i),function(){window.removeEventListener("resize",i),0==(t-=1)&&document.documentElement.style.removeProperty("--vh")}},[i]),o};
|
|
2
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/useVH.ts"],"sourcesContent":["import { useCallback, useEffect, useState } from 'react';\n\nconst VARIABLE_NAME = '--vh';\n\nconst getActualVh = () =>\n // window check for server-side rendering\n typeof window !== 'undefined'\n ? Number((window.innerHeight * 0.01).toFixed(2))\n : 0;\n\nlet count = 0;\n\nconst useVH = (): number => {\n const [vh, setVh] = useState(getActualVh());\n const updateVh = useCallback(() => {\n const newVh = getActualVh();\n\n document.documentElement.style.setProperty(VARIABLE_NAME, `${newVh}px`);\n setVh(newVh);\n }, [setVh]);\n\n useEffect(() => {\n count += 1;\n\n updateVh();\n\n window.addEventListener('resize', updateVh);\n\n return () => {\n window.removeEventListener('resize', updateVh);\n\n count -= 1;\n\n if (count === 0)\n document.documentElement.style.removeProperty(VARIABLE_NAME);\n };\n }, [updateVh]);\n\n return vh;\n};\n\nexport default useVH;\n"],"names":["getActualVh","window","Number","innerHeight","toFixed","count","useState","vh","setVh","updateVh","useCallback","newVh","document","documentElement","style","setProperty","useEffect","addEventListener","removeEventListener","removeProperty"],"mappings":"uBAIMA,EAAc,iBAEA,oBAAXC,OACHC,QAA6B,IAArBD,OAAOE,aAAoBC,QAAQ,IAC3C,GAEFC,EAAQ,iBAEE,iBACQC,WAASN,KAAtBO,OAAIC,OACLC,EAAWC,cAAY,WAC3B,IAAMC,EAAQX,IAEdY,SAASC,gBAAgBC,MAAMC,YAfb,OAe2CJ,QAC7DH,EAAMG,IACL,CAACH,IAmBJ,OAjBAQ,YAAU,WAOR,OANAX,GAAS,EAETI,IAEAR,OAAOgB,iBAAiB,SAAUR,cAGhCR,OAAOiB,oBAAoB,SAAUT,GAIvB,IAFdJ,GAAS,IAGPO,SAASC,gBAAgBC,MAAMK,eAhCjB,UAkCjB,CAACV,IAEGF"}
|
package/dist/index.modern.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{useState as e,useCallback as t,useEffect as n}from"react";const o=()=>"undefined"!=typeof window?Number((.01*window.innerHeight).toFixed(2)):0;let r=0;export default()=>{const[d,i]=e(o()),m=t(()=>{const e=o();document.documentElement.style.setProperty("--vh",`${e}px`),i(e)},[i]);return n(()=>(r+=1,m(),window.addEventListener("resize",m),()=>{window.removeEventListener("resize",m),r-=1,0===r&&document.documentElement.style.removeProperty("--vh")}),[m]),d};
|
|
2
|
-
//# sourceMappingURL=index.modern.js.map
|
package/dist/index.modern.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.modern.js","sources":["../src/useVH.ts"],"sourcesContent":["import { useCallback, useEffect, useState } from 'react';\n\nconst VARIABLE_NAME = '--vh';\n\nconst getActualVh = () =>\n // window check for server-side rendering\n typeof window !== 'undefined'\n ? Number((window.innerHeight * 0.01).toFixed(2))\n : 0;\n\nlet count = 0;\n\nconst useVH = (): number => {\n const [vh, setVh] = useState(getActualVh());\n const updateVh = useCallback(() => {\n const newVh = getActualVh();\n\n document.documentElement.style.setProperty(VARIABLE_NAME, `${newVh}px`);\n setVh(newVh);\n }, [setVh]);\n\n useEffect(() => {\n count += 1;\n\n updateVh();\n\n window.addEventListener('resize', updateVh);\n\n return () => {\n window.removeEventListener('resize', updateVh);\n\n count -= 1;\n\n if (count === 0)\n document.documentElement.style.removeProperty(VARIABLE_NAME);\n };\n }, [updateVh]);\n\n return vh;\n};\n\nexport default useVH;\n"],"names":["getActualVh","window","Number","innerHeight","toFixed","count","vh","setVh","useState","updateVh","useCallback","newVh","document","documentElement","style","setProperty","useEffect","addEventListener","removeEventListener","removeProperty"],"mappings":"iEAEA,MAEMA,EAAc,IAEA,oBAAXC,OACHC,QAA6B,IAArBD,OAAOE,aAAoBC,QAAQ,IAC3C,EAEN,IAAIC,EAAQ,gBAEE,KACZ,MAAOC,EAAIC,GAASC,EAASR,KACvBS,EAAWC,EAAY,KAC3B,MAAMC,EAAQX,IAEdY,SAASC,gBAAgBC,MAAMC,YAfb,UAe2CJ,OAC7DJ,EAAMI,IACL,CAACJ,IAmBJ,OAjBAS,EAAU,KACRX,GAAS,EAETI,IAEAR,OAAOgB,iBAAiB,SAAUR,GAE3B,KACLR,OAAOiB,oBAAoB,SAAUT,GAErCJ,GAAS,EAEK,IAAVA,GACFO,SAASC,gBAAgBC,MAAMK,eAhCjB,UAkCjB,CAACV,IAEGH"}
|
package/dist/index.module.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{useState as e,useCallback as n,useEffect as t}from"react";var r=function(){return"undefined"!=typeof window?Number((.01*window.innerHeight).toFixed(2)):0},o=0;export default function(){var i=e(r()),u=i[0],d=i[1],m=n(function(){var e=r();document.documentElement.style.setProperty("--vh",e+"px"),d(e)},[d]);return t(function(){return o+=1,m(),window.addEventListener("resize",m),function(){window.removeEventListener("resize",m),0==(o-=1)&&document.documentElement.style.removeProperty("--vh")}},[m]),u}
|
|
2
|
-
//# sourceMappingURL=index.module.js.map
|
package/dist/index.module.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.module.js","sources":["../src/useVH.ts"],"sourcesContent":["import { useCallback, useEffect, useState } from 'react';\n\nconst VARIABLE_NAME = '--vh';\n\nconst getActualVh = () =>\n // window check for server-side rendering\n typeof window !== 'undefined'\n ? Number((window.innerHeight * 0.01).toFixed(2))\n : 0;\n\nlet count = 0;\n\nconst useVH = (): number => {\n const [vh, setVh] = useState(getActualVh());\n const updateVh = useCallback(() => {\n const newVh = getActualVh();\n\n document.documentElement.style.setProperty(VARIABLE_NAME, `${newVh}px`);\n setVh(newVh);\n }, [setVh]);\n\n useEffect(() => {\n count += 1;\n\n updateVh();\n\n window.addEventListener('resize', updateVh);\n\n return () => {\n window.removeEventListener('resize', updateVh);\n\n count -= 1;\n\n if (count === 0)\n document.documentElement.style.removeProperty(VARIABLE_NAME);\n };\n }, [updateVh]);\n\n return vh;\n};\n\nexport default useVH;\n"],"names":["getActualVh","window","Number","innerHeight","toFixed","count","useState","vh","setVh","updateVh","useCallback","newVh","document","documentElement","style","setProperty","useEffect","addEventListener","removeEventListener","removeProperty"],"mappings":"iEAEA,IAEMA,EAAc,iBAEA,oBAAXC,OACHC,QAA6B,IAArBD,OAAOE,aAAoBC,QAAQ,IAC3C,GAEFC,EAAQ,iBAEE,iBACQC,EAASN,KAAtBO,OAAIC,OACLC,EAAWC,EAAY,WAC3B,IAAMC,EAAQX,IAEdY,SAASC,gBAAgBC,MAAMC,YAfb,OAe2CJ,QAC7DH,EAAMG,IACL,CAACH,IAmBJ,OAjBAQ,EAAU,WAOR,OANAX,GAAS,EAETI,IAEAR,OAAOgB,iBAAiB,SAAUR,cAGhCR,OAAOiB,oBAAoB,SAAUT,GAIvB,IAFdJ,GAAS,IAGPO,SAASC,gBAAgBC,MAAMK,eAhCjB,UAkCjB,CAACV,IAEGF"}
|
package/dist/index.umd.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):(e||self).reactViewportHeight=t(e.react)}(this,function(e){var t="--vh",n=function(){return"undefined"!=typeof window?Number((.01*window.innerHeight).toFixed(2)):0},o=0;return function(){var r=e.useState(n()),i=r[0],u=r[1],d=e.useCallback(function(){var e=n();document.documentElement.style.setProperty(t,e+"px"),u(e)},[u]);return e.useEffect(function(){return o+=1,d(),window.addEventListener("resize",d),function(){window.removeEventListener("resize",d),0==(o-=1)&&document.documentElement.style.removeProperty(t)}},[d]),i}});
|
|
2
|
-
//# sourceMappingURL=index.umd.js.map
|
package/dist/index.umd.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.umd.js","sources":["../src/useVH.ts"],"sourcesContent":["import { useCallback, useEffect, useState } from 'react';\n\nconst VARIABLE_NAME = '--vh';\n\nconst getActualVh = () =>\n // window check for server-side rendering\n typeof window !== 'undefined'\n ? Number((window.innerHeight * 0.01).toFixed(2))\n : 0;\n\nlet count = 0;\n\nconst useVH = (): number => {\n const [vh, setVh] = useState(getActualVh());\n const updateVh = useCallback(() => {\n const newVh = getActualVh();\n\n document.documentElement.style.setProperty(VARIABLE_NAME, `${newVh}px`);\n setVh(newVh);\n }, [setVh]);\n\n useEffect(() => {\n count += 1;\n\n updateVh();\n\n window.addEventListener('resize', updateVh);\n\n return () => {\n window.removeEventListener('resize', updateVh);\n\n count -= 1;\n\n if (count === 0)\n document.documentElement.style.removeProperty(VARIABLE_NAME);\n };\n }, [updateVh]);\n\n return vh;\n};\n\nexport default useVH;\n"],"names":["VARIABLE_NAME","getActualVh","window","Number","innerHeight","toFixed","count","useState","vh","setVh","updateVh","useCallback","newVh","document","documentElement","style","setProperty","useEffect","addEventListener","removeEventListener","removeProperty"],"mappings":"wQAEA,IAAMA,EAAgB,OAEhBC,EAAc,iBAEA,oBAAXC,OACHC,QAA6B,IAArBD,OAAOE,aAAoBC,QAAQ,IAC3C,GAEFC,EAAQ,SAEE,iBACQC,WAASN,KAAtBO,OAAIC,OACLC,EAAWC,cAAY,WAC3B,IAAMC,EAAQX,IAEdY,SAASC,gBAAgBC,MAAMC,YAAYhB,EAAkBY,QAC7DH,EAAMG,IACL,CAACH,IAmBJ,OAjBAQ,YAAU,WAOR,OANAX,GAAS,EAETI,IAEAR,OAAOgB,iBAAiB,SAAUR,cAGhCR,OAAOiB,oBAAoB,SAAUT,GAIvB,IAFdJ,GAAS,IAGPO,SAASC,gBAAgBC,MAAMK,eAAepB,KAEjD,CAACU,IAEGF"}
|
package/dist/src/src/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from './useVH';
|
package/dist/src/src/useVH.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import '@testing-library/jest-dom/extend-expect';
|