Skip to content

baturox/reactjs-gyroscope

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published