Gathering detailed insights and metrics for @futurejj/react-native-visibility-sensor
Gathering detailed insights and metrics for @futurejj/react-native-visibility-sensor
Gathering detailed insights and metrics for @futurejj/react-native-visibility-sensor
Gathering detailed insights and metrics for @futurejj/react-native-visibility-sensor
Component visibility sensor wrapper to sense whether or not a component is in viewport with configurable inset thresholds.
npm install @futurejj/react-native-visibility-sensor
Typescript
Module System
Min. Node Version
Node Version
NPM Version
40.1
Supply Chain
53.4
Quality
81.2
Maintenance
50
Vulnerability
93.6
License
TypeScript (74.75%)
JavaScript (25.25%)
Total Downloads
31,927
Last Day
142
Last Week
759
Last Month
3,800
Last Year
31,927
14 Stars
127 Commits
1 Forks
10 Branches
6 Contributors
Latest Version
1.3.8
Package Id
@futurejj/react-native-visibility-sensor@1.3.8
Unpacked Size
36.23 kB
Size
10.41 kB
File Count
26
NPM Version
10.9.0
Node Version
22.12.0
Publised On
16 Dec 2024
Cumulative downloads
Total Downloads
Last day
-21.5%
142
Compared to previous day
Last week
-36.4%
759
Compared to previous week
Last month
52.7%
3,800
Compared to previous month
Last year
0%
31,927
Compared to previous year
2
25
🔍 Component visibility sensor wrapper to sense whether or not a component is in viewport with configurable inset thresholds.
Using yarn
1yarn add @futurejj/react-native-visibility-sensor
using npm:
1npm install @futurejj/react-native-visibility-sensor
1import React from 'react'; 2import { ScrollView, Text } from 'react-native'; 3import { VisibilitySensor } from '@futurejj/react-native-visibility-sensor'; 4 5export default function VisibilitySensorExample() { 6 const [isInView, setIsInView] = React.useState(false); 7 8 function checkVisible(isVisible: boolean) { 9 if (isVisible) { 10 setIsInView(isVisible); 11 } else { 12 setIsInView(isVisible); 13 } 14 } 15 16 return ( 17 <ScrollView> 18 <VisibilitySensor 19 onChange={(isVisible) => checkVisible(isVisible)} 20 threshold={{ 21 left: 100, 22 right: 100, 23 }} 24 style={[styles.item, { backgroundColor: isInView ? 'green' : 'red' }]}> 25 <Text>This View is currently visible? {isInView ? 'yes' : 'no'}</Text> 26 </VisibilitySensor> 27 </ScrollView> 28 ); 29}
VisibilitySensorProps
extends ViewProps
from React Native, which includes common properties for all views, such as style
, onLayout
, etc.
Property | Type | Required | Description |
---|---|---|---|
onChange | (visible: boolean) => void | Yes | Callback function that fires when visibility changes. |
disabled | boolean | No | If true , disables the sensor. |
triggerOnce | boolean | No | If true , the sensor will only trigger once. |
delay | number | undefined | No | The delay in milliseconds before the sensor triggers. |
threshold | VisibilitySensorThreshold | No | Defines the part of the view that must be visible for the sensor to trigger. |
Additionally, all properties from ViewProps
are also applicable.
Property | Type | Required | Description |
---|---|---|---|
top | number | No | The top threshold value for visibility. |
bottom | number | No | The bottom threshold value for visibility. |
left | number | No | The left threshold value for visibility. |
right | number | No | The right threshold value for visibility. |
See the contributing guide to learn how to contribute to the repository and the development workflow.
MIT
No vulnerabilities found.
No security vulnerabilities found.