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
npm install @rooks/use-visibility-sensor
Typescript
Module System
Node Version
NPM Version
70.3
Supply Chain
99.5
Quality
75.9
Maintenance
100
Vulnerability
100
License
TypeScript (95.75%)
JavaScript (3.99%)
Shell (0.17%)
CSS (0.1%)
Total Downloads
470,656
Last Day
150
Last Week
995
Last Month
5,007
Last Year
77,518
3,227 Stars
3,056 Commits
217 Forks
20 Watching
34 Branches
72 Contributors
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
-23.9%
150
Compared to previous day
Last week
-21.8%
995
Compared to previous week
Last month
28.2%
5,007
Compared to previous month
Last year
-17.1%
77,518
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
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 3/17 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
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
Reason
38 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-12-16
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