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 🙏

© 2024 – Pkg Stats / Ryan Hefner

rn-intersection-observer

v0.3.0

Published

Intersection observer for complex or embedded react native view

Downloads

300

Readme

react-native-intersection-observer

react-native-intersection-observer is a React Native implementation of Intersection Observer. An easier way to detect "View" exposure in complex application.

English | 中文

Installation

npm install rn-intersection-observer

Usage

Target view

import { IntersectionObserverView } from 'rn-intersection-observer';

// ...

<IntersectionObserverView
    scope="YourOwnScope"
    thresholds={[0.8]}
    onIntersectionChange={onTagIntersectionChange}
>
 {/* your own view */}
</IntersectionObserverView>

Trigger detection from React Native

import { IntersectionObserver } from 'rn-intersection-observer';

// ...

const onScroll = useCallback(
    (event) => {
        IntersectionObserver.emitEvent('YourOwnScope');
    },
    [],
);

return (
    <ScrollView onScroll={onScroll}>
        {/* Scroll view contains IntersectionObserverView */}
    </ScrollView>
);

Trigger detection from Native (Android example)

getReactApplicationContext()
  .getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
  .emit("IntersectionObeserverEvent", { scope: 'YourOwnScope' });

Props & Params

1) IntersectionObserver / IntersectionObserverView

| Props | Params Type | Description | | :----- | :--- | :--- | | scope | string | Scope of the target View, required in event trigger. | | rootMargin | {top: number, left: number, bottom: number, right: number} | Distance from screen edge of detect area. | | thresholds | number[] | Intersection ratios which should trigger intersection callbacks. | | throttle | number | Throttle time between each detection(ms). |

2) Intersection Callback (onIntersectionChange)

Callback parameters contained info of each target which triggered intersection callback:

| Params | Params Type | Description | | :----- | :--- | :--- | | boundingClientRect | {top: number, left: number, bottom: number, right: number} | Position of target View's edge. | | intersectionRatio | number | Intersection ratio of target View in detect area | | intersectionRect | {top: number, left: number, bottom: number, right: number} | Position of intersection area's edge. | | target | Ref | Ref of target View | | isInsecting | boolean | Determine current intersection ratio is larger than any threshold. |

PS:Different from IntersectionObserver, IntersectionObserverView provides single parameter.

License

MIT