1.6.1 β€’ Published 3 years ago

react-native-accelerometer-parallax v1.6.1

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

React Native Accelerometer Parallax 🍻

Simple Accelerometer animation react-native library for animate translateXY some View RN for IOS and Android 🍎 πŸ€–

That now Library is supporting and work βš™οΈ

Library stand by expo-sensors and react-native-reanimated. TS only.

video example source link πŸͺ

video example not loads πŸ€–

repository code example from video*

Install

  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

Usage

1. Wrap your root App.tsx to ParallaxProvider to provide context value for hooks.

import React from 'react'
import {ParallaxProvider} from 'react-native-accelerometer-parallax'

const App = () => {
    return <ParallaxProvider>
        <SomeStack/> 
    </ParallaxProvider>
}

export default App

2. Get context value to use animated value (hook shared value from react-native-reanimated)

import {useParallax} from 'react-native-accelerometer-parallax'


const Screen = () => {
    const {animStyle} = useParallax()

    return <View style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}>
        <Text>Parallax text test</Text>
    </View>
}

3. Wrap your some component to Animated.View from react-native-reanimated and pass animated style to style prop

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 <View style={{flex: 1, justifyContent: 'center', alignItems: 'center'}}>
      <Animated.View style={animStyle}>
         <Text>Parallax text test</Text>
      </Animated.View>
   </View>
}

const App = () => {
   return <ParallaxProvider>
      <Screen/>
   </ParallaxProvider>
}

export default App

4. Final - βœ¨πŸ“² Look at work view motion!

Documentation.

1. useParallax(config: ParallaxConfig): ParallaxObject

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 (for use it or interpolate, for example style={{opacity: posY.value}})

  • posY: Animated.SharedValue (equal posX)

#Contact

✨Lib going to grow up, and you can send your questions and offers to my telegram Stepan_Turchenko πŸ›¬

1.6.1

3 years ago

1.6.0

3 years ago

1.5.6

3 years ago

1.5.5

3 years ago

1.5.4

3 years ago

1.5.3

3 years ago

1.5.2

3 years ago

1.5.1

3 years ago

1.5.0

3 years ago

1.4.10

3 years ago

1.4.9

3 years ago

1.4.8

3 years ago

1.4.5

3 years ago

1.4.4

3 years ago

1.4.3

3 years ago

1.4.2

3 years ago

1.4.1

3 years ago

1.4.0

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.12

3 years ago

1.2.11

3 years ago

1.2.10

3 years ago

1.2.9

3 years ago

1.2.8

3 years ago

1.2.7

3 years ago

1.2.6

3 years ago

1.2.5

3 years ago

1.2.4

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.1.10

3 years ago

1.1.9

3 years ago

1.1.8

3 years ago

1.1.7

3 years ago

1.1.6

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago