Skip to content

Commit c00e27f

Browse files
committed
update build, code sandbox link, v0.3.0-beta.0
1 parent 81a46c6 commit c00e27f

File tree

5 files changed

+20
-21
lines changed

5 files changed

+20
-21
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
![npm](https://img.shields.io/npm/v/use-viewport-sizes.svg?color=blue) ![David](https://img.shields.io/david/rob2d/use-viewport-sizes.svg) ![npm](https://img.shields.io/npm/dw/use-viewport-sizes.svg?color=red) ![GitHub issues](https://img.shields.io/github/issues-raw/rob2d/use-viewport-sizes.svg) ![NPM](https://img.shields.io/npm/l/use-viewport-sizes.svg)
44

5-
a tiny React hook which allows you to track visible window viewport size in your components w/ an optional debounce or custom memo function for updates for optimal rendering.
5+
a tiny React hook which allows you to track visible window viewport size in your components w/ an optional debounce and
6+
other flexible options for optimal usage.
67

78
## Installation ##
89

@@ -27,7 +28,7 @@ npm install -D use-viewport-sizes
2728
<img src="./doc/use-viewport-sizes.gif" />
2829

2930
*Interact with the example shown on CodeSandox* @
30-
[https://codesandbox.io/s/react-hooks-viewport-sizes-demo-forked-7rr9c](https://codesandbox.io/s/react-hooks-viewport-sizes-demo-forked-7rr9c)
31+
[https://codesandbox.io/s/react-hooks-viewport-sizes-demo-forked-7rr9c](https://codesandbox.io/s/react-hooks-viewport-sizes-demo-forked-i8urr?file=/src/index.js&resolutionWidth=1401&resolutionHeight=891)
3132

3233
</center>
3334

build/index.d.ts

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
declare module 'use-viewport-sizes' {
2+
export type VPSizesHasher = ({ vpW: number, vpH: number }) => String;
3+
export type VPSizesOptions ={
4+
debounceTimeout?: number,
5+
hasher?: VPSizesHasher,
6+
dimension?: 'w'|'h'|'both' = 'both'
7+
};
8+
29
/**
310
* Hook which observes viewport dimensions. Returns [width, height] of
4-
* current visible viewport of app.
5-
*
6-
* If no input specified, returns the [width, height] when the window changes.
7-
*
8-
* If input is specified as a number, it interprets this as the number of
9-
* miliseconds to debounce before updates.
10-
*
11-
* If the input is specified as a function, it accepts a callback
12-
* with the viewport width and height passed in the first arg as
13-
* { vpW, vpH }, and will only return a new value and update when
14-
* the hash-value returned changes.
11+
* current visible viewport of app, or the specific dimension
1512
*/
1613
export default function(
17-
input:number | (({ vpW: number, vpH: number }) => String)
18-
):[vpW: number, vpH: number];
14+
input:number | VPSizesHasher | VPSizesOptions
15+
):([vpW: number, vpH: number, triggerResize: Function] |
16+
[dimension: number, triggerResize:Function]
17+
);
1918
}

build/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
{
22
"name": "use-viewport-sizes",
3-
"version": "0.2.12",
3+
"version": "0.3.0-beta.0",
44
"description": "a tiny React hook which allows you to track visible window viewport size in your components w/ an optional debounce or custom memo function for updates for optimal rendering.",
55
"main": "./build/index.js",
66
"types": "./build/index.d.ts",
77
"scripts": {
88
"start": "webpack --watch",
99
"build": "webpack",
10-
"dev": "webpack-dev-server --env testServer --mode development --open"
10+
"dev": "webpack-dev-server --env testServer --mode development --open",
11+
"prepublishOnly": "npm run build"
1112
},
12-
"peerDependencies": {
13+
"peer Dependencies": {
1314
"react": "^16.8.6"
1415
},
1516
"devDependencies": {

src/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,6 @@ function useViewportSizes(input) {
105105
input?.debounceTimeout
106106
) || 0;
107107

108-
const throttleTimeout = input?.throttleTimeout || 0;
109-
110108
const dimension = input?.dimension || 'both';
111109

112110
const options = {

0 commit comments

Comments
 (0)