add reanimated animation connected with accelerometer context animation from wrapper
Library stand by expo-sensors and react-native-reanimated. TS only.
video example source link πͺ
repository code example from video*
1. Install last version react-native-reanimated (v2.0.0
or more)
2. Install last version expo-sensors
3. Install library
> yarn add react-native-accelerometer-parallax
``tsx
import React from 'react'
import {ParallaxProvider} from 'react-native-accelerometer-parallax'
const App = () => {
return
}
export default App
`
`tsx
import {useParallax} from 'react-native-accelerometer-parallax'
const Screen = () => {
const {animStyle} = useParallax()
return
}
`
`tsx
import React from 'react'
import {useParallax} from 'react-native-accelerometer-parallax'
import Animated from 'react-native-reanimated'
import {View, Text} from 'react-native'
import {ParallaxProvider} from 'react-native-accelerometer-parallax'
const Screen = () => {
const {animStyle} = useParallax()
return
}
const App = () => {
return
}
export default App
``
ParallaxConfig
- sensitivity: number - (default 1, sensitivity accelerometer rotate and multiple to animate shared value )
ParallaxObject
- animStyle: {transform:[{translateX: number},{translateY: number}]} (for pass to Animated.View style prop)
- posX: Animated.SharedValue
- posY: Animated.SharedValue
#Contact
β¨Lib going to grow up, and you can send your questions and offers to my telegram Stepan_Turchenko π¬