react-accelerometer-field
v1.0.2
Published
Uses the device's Accelerometer as a React Component. Forked to fix React-Prop-Types.
Downloads
202
Maintainers
Readme
React-Accelerometer-Field
Allows you to take advantage of the device's accelerometer on a very easy and uncomplicated way. Forked to fix React prop-types and to be deployable on netlify.
Installation
npm install --save react-accelerometer-field
// or
yarn add react-accelerometer-field
Usage
import React, { Component, PropTypes } from 'react'
import { render } from 'react-dom'
import ReactAccelerometer from 'react-accelerometer-field'
const AwesomeComponent = () => (
<ReactAccelerometer>
{(position, rotation) => (
<ul>
<li>x: {position.x}</li>
<li>y: {position.y}</li>
<li>z: {position.z}</li>
<li>rotation alpha: {rotation.alpha}</li>
<li>rotation beta: {rotation.beta}</li>
<li>rotation gamma: {rotation.gamma}</li>
</ul>
)}
</ReactAccelerometer>
)
render(<AwesomeComponent />, document.querySelector('#app'))
License
MIT