reactjs-gyroscope

1.1.1 • Public • Published

reactjs-gyroscope

This package allows to read gyroscope data Gyroscope.

Installation

yarn add reactjs-gyroscope

Usage

import { useEffect, useState } from 'react'
import { getGyroscope, gyroscopePermission } from 'reactjs-gyroscope';

function App() {
  const [start, setStart] = useState(false);

  useEffect(() => {
    if (start) {
      getGyroscope((event) => {
        console.log(event)
      });
    }
  }, [start]);

  return (<>
    <button onClick={() => {
      gyroscopePermission().then(response => {
        if (response) {
          setStart(true);
        }
      });
    }}>Start</button>
  </>);
}

export default App;

Notes

Needs permission for deviceorientation event. (a.k.a. only using HTTPS).

License

LGPL-3.0

Dependencies (0)

    Dev Dependencies (6)

    Package Sidebar

    Install

    npm i reactjs-gyroscope

    Weekly Downloads

    0

    Version

    1.1.1

    License

    LGPL

    Unpacked Size

    2.07 kB

    Total Files

    3

    Last publish

    Collaborators

    • baturox