Gathering detailed insights and metrics for @rooks/use-visibility-sensor
Gathering detailed insights and metrics for @rooks/use-visibility-sensor
Gathering detailed insights and metrics for @rooks/use-visibility-sensor
Gathering detailed insights and metrics for @rooks/use-visibility-sensor
Essential React custom hooks ⚓ to super charge your components!
npm install @rooks/use-visibility-sensor
Typescript
Module System
Node Version
NPM Version
73.5
Supply Chain
100
Quality
75.9
Maintenance
100
Vulnerability
100
License
TypeScript (74.9%)
MDX (21.64%)
JavaScript (3.22%)
Shell (0.13%)
CSS (0.11%)
Total Downloads
493,773
Last Day
20
Last Week
1,052
Last Month
4,469
Last Year
56,576
MIT License
3,273 Stars
3,085 Commits
220 Forks
19 Watchers
35 Branches
73 Contributors
Updated on Jun 14, 2025
Minified
Minified + Gzipped
Latest Version
4.11.2
Package Id
@rooks/use-visibility-sensor@4.11.2
Unpacked Size
22.99 kB
Size
6.46 kB
File Count
13
NPM Version
lerna/3.22.1/node@v12.22.1+x64 (linux)
Node Version
12.22.1
Cumulative downloads
Total Downloads
Last Day
25%
20
Compared to previous day
Last Week
-20.5%
1,052
Compared to previous week
Last Month
-6.4%
4,469
Compared to previous month
Last Year
-42.1%
56,576
Compared to previous year
1
npm install rooks
or
yarn add rooks
Rooks is completely treeshakeable and if you use only 1 of the 50+ hooks in the package, only that hook will be bundled with your code. Your bundle will only contain the hooks that you need. Cheers!
Visibility sensor hook for React.
npm install --save @rooks/use-visibility-sensor
1import useVisibilitySensor from "@rooks/use-visibility-sensor"
1 2function Demo() { 3 const rootNode = useRef(null); 4 const { isVisible, visibilityRect } = useVisibilitySensor(rootNode, { 5 intervalCheck: false, 6 scrollCheck: true, 7 resizeCheck: true 8 }); 9 return ( 10 <div ref={rootNode}> 11 <p> 12 {isVisible ? "Visible" : isVisible === null ? "Null" : "Not Visible"} 13 </p> 14 </div> 15 ); 16} 17 18render(<Demo/>)
It checks whether an element has scrolled into view or not. A lot of the logic is taken from react-visibility-sensor and is rewritten for the hooks proposal.
Note: This is using the new React Hooks API Proposal which is subject to change until React 16.7 final.
You'll need to install
react
,react-dom
, etc at^16.7.0-alpha.0
Returned object attributes | Type | Description |
---|---|---|
isVisible | Boolean | Is Ref visible or not |
visibilityRect | Object | VisibilityRectangle containing coordinates of the container |
The first argument of the useVisibilitySensor
hook is a ref, the second argument is an options object. The available options are as follow:
intervalCheck: false
- Accepts int | bool
, if an int
is supplied, that will be the interval in ms
and it keeps checking for visibility
partialVisibility: false
- Accepts bool | string
: Tells the hook if partial visibility should be considered as visibility or not. Accepts false
and directions top
, bottom
, left
and right
containment: null
- A DOMNode
element which defaults to window
. The element relative to which visibility is checked against
scrollCheck: true
- A bool
to determine whether to check for scroll behavior or not
scrollDebounce: 250
- The debounce ms for scroll
scrollThrottle: -1
- The throttle ms for scroll. If throttle > -1, debounce is ignored.
resizeCheck: false
- A bool
to determine whether to check for resize behavior or not
resizeDebounce: 250
- The debounce ms for resize
resizeThrottle: -1
- The throttle ms for resize. If throttle > -1, debounce is ignored.
shouldCheckOnMount: true
- A bool
which determines whether an initial check on first render should happen or not.
minTopValue: 0
- An int
top value to determine what amount of top visibility should be considered for visibility
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
29 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 10
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
9 existing vulnerabilities detected
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
Found 1/28 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-06-09
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More