Gathering detailed insights and metrics for @ilyahas/react-native-inviewport
Gathering detailed insights and metrics for @ilyahas/react-native-inviewport
Gathering detailed insights and metrics for @ilyahas/react-native-inviewport
Gathering detailed insights and metrics for @ilyahas/react-native-inviewport
Detect if component is in device viewport
npm install @ilyahas/react-native-inviewport
Typescript
Module System
Node Version
NPM Version
68.8
Supply Chain
98.1
Quality
75.5
Maintenance
100
Vulnerability
99.6
License
JavaScript (100%)
Total Downloads
12,703
Last Day
18
Last Week
116
Last Month
563
Last Year
7,860
1 Stars
38 Commits
2 Branches
1 Contributors
Latest Version
0.2.2
Package Id
@ilyahas/react-native-inviewport@0.2.2
Unpacked Size
10.05 kB
Size
4.05 kB
File Count
9
NPM Version
6.14.11
Node Version
14.16.0
Publised On
06 Mar 2023
Cumulative downloads
Total Downloads
Last day
-43.8%
18
Compared to previous day
Last week
-37%
116
Compared to previous week
Last month
0%
563
Compared to previous month
Last year
62.3%
7,860
Compared to previous year
No dependencies detected.
Based on @coffeebeanslabs/react-native-inviewport.
*Fix freezing app with "Please report: Excessive number of pending callbacks: 501"
Warning.
If you have the same issue, try this npm.
Detect if component is in device viewport. I based this off:https://github.com/yamill/react-native-inviewport with some slight modifications.
npm i @ilyahas/react-native-inviewport
Assuming you already setup your component, here's a quick example.
import InViewPort from "@coffeebeanslabs/react-native-inviewport";
checkVisible = isVisible => this.setState({visible: isVisible});
render() {
return (
<ScrollView style={{flex: 1}}>
<InViewPort onChange={(isVisible) => this.checkVisible(isVisible)}>
<View style={{flex: 1, height: 200, backgroundColor: 'blue'}}>
<Text style={{color: 'white'}}>View is visible? {this.state.visible}</Text>
</View>
</InViewPort>
</ScrollView>
);
}
A number that indicates milliseconds of periodically delay to check component visibility. By default it is 100ms. Example:
<InViewPort delay={1000}>
...
</InViewPort>
InviewPort always keep checking the component with a delay of 100ms. This props can be used for disabling checking for component visibility. Example:
<InViewPort disabled={true}>
...
</InViewPort>
Callback function that is called whenever the component visibility change. It returns true
or false
.
Example:
const onChangeVisibility = isVisible => console.log('is component visible ', isVisible);
<InViewPort onChange={onChangeVisibility}>
...
</InViewPort>
Let's assume you want to check whether a component at scroll end has displayed or not and it is rendering components asynchronise on scrollview so you can use onScroll
event listener on scrollview.
Example
import InViewPort from "@coffeebeanslabs/react-native-inviewport";
this.state = {visible: false, isScrolling: false};
checkVisible = isVisible => this.setState({visible: isVisible});
const onScroll = () => this.setState({isScrolling: true});
render() {
return (
<ScrollView style={{flex: 1}} onScroll={onScroll}>
//list of images
//<Image..... />
//.......
{isScrolling && <InViewPort onChange={(isVisible) => this.checkVisible(isVisible)}>
<View style={{flex: 1, height: 200, backgroundColor: 'blue'}}>
<Text style={{color: 'white'}}>View is visible? {this.state.visible}</Text>
</View>
</InViewPort>}
</ScrollView>
);
}
No vulnerabilities found.
No security vulnerabilities found.