2.7.1 • Published 3 years ago
@wbe/use-bounding-client-rect v2.7.1
@wbe/use-bounding-client-rect
This React hook allow to get dynamically getBoundClientRect
of any React Ref.
Installation
$ npm install -s @wbe/use-bounding-client-rect
How to use
Basic usage:
// ...
import { useBoundingClientRect } from "@wbe/use-window-size";
const App = () => {
// get ref
const rootRef = useRef();
// get ref properties
const refRect = useBoundingClientRect(rootRef);
return (
<div ref={rootRef}>
{refRect.x}, {refRect.y} ...
</div>
);
};
Parameters
params | type | description | default value |
---|---|---|---|
pRef | MutableRefObject | element ref | / |
pListener | EListener | kind of listener | EListener.ON_INIT |
pListener options are:
ON_INIT
: listen rect only on initON_SCROLL
: listen rect on init + scrollON_RESIZE
: listen rect on init + resizeON_SCROLL_AND_RESIZE
: listen rect on init + scroll + resize
Returned
The hook return an object (ClientRect interface):
{
"x": number,
"y": number,
"width": number,
"height": number,
"top": number,
"right": number,
"bottom": number,
"left": number
}
2.7.1
3 years ago
2.7.0
3 years ago
2.4.0
4 years ago
2.3.0
4 years ago
2.2.0-alpha.0
4 years ago
2.1.0
4 years ago
2.0.0
4 years ago
2.0.0-alpha.11
4 years ago
2.0.0-alpha.10
4 years ago
2.0.0-alpha.7
4 years ago
2.0.0-alpha.6
4 years ago
2.0.0-alpha.3
4 years ago
2.0.0-alpha.0
4 years ago
2.0.0-alpha.1
4 years ago
2.0.0-alpha.2
4 years ago
1.6.0
4 years ago
1.5.0
4 years ago
1.4.2
5 years ago
1.4.2-alpha.0
5 years ago
1.4.1
5 years ago
1.4.0-alpha.0
5 years ago
1.4.0
5 years ago
1.3.0
5 years ago
1.2.0
5 years ago
1.1.0-alpha.0
5 years ago
1.0.0-alpha.0
5 years ago
0.0.30
5 years ago
0.0.29
5 years ago
0.0.28
5 years ago
0.0.27
5 years ago
0.0.26
5 years ago
0.0.25
5 years ago
0.0.24
5 years ago
0.0.22
5 years ago
0.0.23
5 years ago
0.0.21
5 years ago
0.0.20
5 years ago
0.0.19
5 years ago
0.0.18
5 years ago
0.0.17
5 years ago
0.0.16
5 years ago
0.0.14
5 years ago
0.0.13
5 years ago