🚀 Launch Week Day 5:Introducing Immutable Scans.Learn More
Socket
Book a DemoInstallSign in
Socket

@futurejj/react-native-visibility-sensor

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@futurejj/react-native-visibility-sensor

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

Source
npmnpm
Version
1.4.5
Version published
Weekly downloads
17K
0.11%
Maintainers
1
Weekly downloads
 
Created
Source

@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

Visibility Sensor demo

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.

PropertyTypeRequiredDescription
onChange(visible: boolean) => voidYesCallback function that fires when visibility changes.
onPercentChange(percentVisible: number) => voidNoCallback function that fires when visibility % changes.
disabledbooleanNoIf true, disables the sensor.
triggerOncebooleanNoIf true, the sensor will only trigger once.
delaynumber or undefinedNoThe delay in milliseconds before the sensor triggers.
thresholdVisibilitySensorThresholdNoDefines the part of the view that must be visible for the sensor to trigger.

Additionally, all properties from ViewProps are also applicable.

VisibilitySensorThreshold

PropertyTypeRequiredDescription
topnumberNoThe top threshold value for visibility.
bottomnumberNoThe bottom threshold value for visibility.
leftnumberNoThe left threshold value for visibility.
rightnumberNoThe right threshold value for visibility.

Notes

Contributing

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

License

MIT

Support the project

LiberPay_Donation_Button           Paypal_Donation_Button           Paypal_Donation_Button

❤️ Thanks to

Keywords

react-native

FAQs

Package last updated on 03 Dec 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts