react-native-window-sensor
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

react-native-window-sensor

Sensor component to get components position on screen

Note:

  • When the view in a flatlist is not visible, the value of x and y can be both 0

Installation

npm install react-native-window-sensor
cd ios && pod install

Usage

import { WindowSensorView } from "react-native-window-sensor";

// ...

const handleMeasure = (e) => {
  console.log('4 corners', e.nativeEvent);
}

const handleOnViewPort = (e) => {
  const {
    intersectionAreaPercentage,
    intersectionHeight,
    intersectionWidth
  } = e;
}

<WindowSensorView
  screen={'screenName'}
  id={`sensorId`}
  onViewPort={handleOnViewPort} // this return intersectionArea, intersectionHeight and intersection Width of parent component
  onCustomMeasure={handleMeasure} // this return 4 corners of parent component
/>

Ask sensor to measure again:

import { SensorManager } from 'react-native-window-sensor';

SensorManager.callMeasureForScreen(navigation.state.routeName);
SensorManager.callMeasure(idsArray); // measure by id

License

MIT


Made with create-react-native-library

Package Sidebar

Install

npm i react-native-window-sensor

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

81.8 kB

Total Files

42

Last publish

Collaborators

  • triracle