1.0.1 • Published 1 year ago

react-native-window-sensor v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

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

1.0.1

1 year ago

1.0.0

1 year ago

0.1.2

1 year ago

0.1.1

3 years ago

0.1.0

3 years ago