npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@futurejj/react-native-visibility-sensor

v1.4.5

Published

A React Native wrapper to check whether a component is in the view port to track impressions and clicks

Downloads

81,246

Readme

@futurejj/react-native-visibility-sensor

🔍 Component visibility sensor wrapper to sense whether or not a component is in viewport with configurable inset thresholds & percent visibility callback.

npm version License Workflow Status Android iOS Web GitHub issues TS Expo Snack NPM Downloads npm bundle size

Use Cases

  • Lazy Loading: Load images/content only when visible to optimize performance in feeds, galleries, charts or webviews.
  • Scroll Animations: Trigger animations (e.g., fade-ins, slides) for components entering the viewport.
  • Analytics Tracking: Log impressions for ads/banners when visible for a set duration or percentage.
  • Dynamic UI & Optimization: Pause/resume videos, cleanup out of screen components or timers based on component visibility in feeds or carousels.

Installation

Using yarn

yarn add @futurejj/react-native-visibility-sensor

using npm:

npm install @futurejj/react-native-visibility-sensor

Usage

import React, { useState } from 'react';
import { ScrollView, Text } from 'react-native';
import { VisibilitySensor } from '@futurejj/react-native-visibility-sensor';

export default function VisibilitySensorExample() {
  const [isVisible, setIsVisible] = useState(false);
  const [percentVisible, setPercentVisible] = useState<number>(0);

  return (
    <ScrollView>
      <VisibilitySensor
        onChange={setIsVisible}
        onPercentChange={setPercentVisible} // optional callback for % change
        threshold={{ top: 100, bottom: 100 }}
        style={[styles.item, { backgroundColor: isVisible ? 'green' : 'red' }]}>
          
        {/* Visibility state */}
        <Text>This View is currently visible? {isVisible ? 'yes' : 'no'}</Text>

        {/* Percent visibility state */}
        <Text>{`Percent visible: ${percentVisible}%`}</Text>
      </VisibilitySensor>
    </ScrollView>
  );
}

Properties

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. | | onPercentChange | (percentVisible: number) => void | No | 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 or 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.


VisibilitySensorThreshold

| 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. |


Notes

  1. ⚠️ Facing problem on Android? Refer this discussion: https://github.com/JairajJangle/react-native-visibility-sensor/pull/1#issuecomment-2251569005

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

Support the project

❤️ Thanks to