doong-jo / react-device-orientation-hook

React Custom Hook using Device Orientation Web API

Home Page:https://www.npmjs.com/package/react-device-orientation-hook

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

react-device-orientation-hook

License: MIT CodeQL

Demo

Usage

📌 Device Orientation Event works only in HTTPS for security reasons.

npm i react-device-orientation-hook
import useDeviceOrientation from 'react-device-orientation-hook;

function Component() {
  const { transformStyle, resetPivotOrientation } = useDeviceOrientation();

  return (
    <>
      <div style={transformStyle} onClick={resetPivotOrientation} >
        Hello World!
      </div>
      <p>Touch text and Revise orientation</p>
    </>
  );
}

Device Orientation Web API Spec

Development

Testing

npm run test

Building

npm run build

Storybook

To run a live-reload Storybook server on your local machine:

npm run storybook

About

React Custom Hook using Device Orientation Web API

https://www.npmjs.com/package/react-device-orientation-hook

License:MIT License


Languages

Language:TypeScript 67.1%Language:JavaScript 31.2%Language:SCSS 1.8%