{"id":20660942,"url":"https://github.com/lucasmotta/react-accelerometer","last_synced_at":"2025-10-11T03:42:56.237Z","repository":{"id":140781036,"uuid":"80827718","full_name":"lucasmotta/react-accelerometer","owner":"lucasmotta","description":"Uses the device's Accelerometer as a React Component","archived":false,"fork":false,"pushed_at":"2020-05-10T00:23:35.000Z","size":59,"stargazers_count":14,"open_issues_count":2,"forks_count":8,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-05-28T03:06:02.569Z","etag":null,"topics":["accelerometer","javascript","react","react-motion"],"latest_commit_sha":null,"homepage":"http://react-accelerometer.groselha.xyz","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lucasmotta.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-02-03T12:37:51.000Z","updated_at":"2024-02-17T17:22:27.000Z","dependencies_parsed_at":null,"dependency_job_id":"c6ea4759-dc32-487d-9d51-6ec9737dd0ab","html_url":"https://github.com/lucasmotta/react-accelerometer","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/lucasmotta/react-accelerometer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucasmotta%2Freact-accelerometer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucasmotta%2Freact-accelerometer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucasmotta%2Freact-accelerometer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucasmotta%2Freact-accelerometer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lucasmotta","download_url":"https://codeload.github.com/lucasmotta/react-accelerometer/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lucasmotta%2Freact-accelerometer/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262545027,"owners_count":23326656,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["accelerometer","javascript","react","react-motion"],"created_at":"2024-11-16T19:06:36.938Z","updated_at":"2025-10-11T03:42:56.158Z","avatar_url":"https://github.com/lucasmotta.png","language":"JavaScript","readme":"# React-Accelerometer\n[![Build Status](https://travis-ci.org/lucasmotta/react-accelerometer.svg?branch=master)](https://travis-ci.org/lucasmotta/react-accelerometer)\n\nAllows you to take advantage of the device's accelerometer on a very easy and uncomplicated way.\n\n## Installation\n```js\nnpm install --save react-accelerometer\n// or\nyarn add react-accelerometer\n```\n\n## Usage\n```js\nimport React, { Component, PropTypes } from 'react'\nimport { render } from 'react-dom'\nimport ReactAccelerometer from 'react-accelerometer'\n\nconst AwesomeComponent = () =\u003e (\n  \u003cReactAccelerometer\u003e\n    {(position, rotation) =\u003e (\n      \u003cul\u003e\n        \u003cli\u003ex: {position.x}\u003c/li\u003e\n        \u003cli\u003ey: {position.y}\u003c/li\u003e\n        \u003cli\u003ez: {position.z}\u003c/li\u003e\n        \u003cli\u003erotation alpha: {rotation.alpha}\u003c/li\u003e\n        \u003cli\u003erotation beta: {rotation.beta}\u003c/li\u003e\n        \u003cli\u003erotation gamma: {rotation.gamma}\u003c/li\u003e\n      \u003c/ul\u003e\n    )}\n  \u003c/ReactAccelerometer\u003e\n)\n\nrender(\u003cAwesomeComponent /\u003e, document.querySelector('#app'))\n```\n\n## Props\n\n```js\nstatic propTypes = {\n  /**\n   * You have to pass a function as the children and return a valid\n   * React component. If the device supports the \"devicemotion\" API,\n   * this function will receive two arguments:\n   *  - pos \u003cObject\u003e - with the \"x\", \"y\", \"z\" properties\n   *  - rotation \u003cObject\u003e - with the \"alpha\", \"beta\", \"gamma\"\n   */\n  children: PropTypes.func.isRequired,\n  /**\n   * Multiplies the `x`, `y` and `z` positions by this amount\n   * @default 1\n   */\n  multiplier: PropTypes.bool,\n  /**\n   * Takes in consideration the gravity or not\n   * @default true\n   */\n  useGravity: PropTypes.bool,\n}\n```\n\n\n## React-Accelerometer + React-Motion\n\nI highly recommend you to combine this component with [React-Motion](https://github.com/chenglou/react-motion) to get a smoother transition between the accelerometer's values:\n\n```js\nimport React, { Component, PropTypes } from 'react'\nimport { render } from 'react-dom'\nimport ReactAccelerometer from 'react-accelerometer'\nimport { Motion, spring } from 'react-motion'\n\n/* Combining React-Accelerometer with React-Motion */\nconst ReactAccelerometerMotion = ({ children }) =\u003e (\n  \u003cReactAccelerometer\u003e\n    {({ x, y }) =\u003e (\n      \u003cMotion style={{ x: spring(x), y: spring(y) }}\u003e\n        {pos =\u003e children(pos)}\n      \u003c/Motion\u003e\n    )}\n  \u003c/ReactAccelerometer\u003e\n)\n\nconst AwesomeComponent = () =\u003e (\n  \u003cReactAccelerometerMotion\u003e\n    {({ x, y }) =\u003e (\n      \u003cimg\n        src='image.jpg'\n        style={{ transform: `translate3d(${x}px, ${y}px, 0)` }}\n      /\u003e\n    )}\n  \u003c/ReactAccelerometerMotion\u003e\n)\n\nrender(\u003cAwesomeComponent /\u003e, document.querySelector('#app'))\n```\n\n## Test\n```js\nnpm test\n// or\nyarnpkg test\n```\n\n## License\n\nMIT\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucasmotta%2Freact-accelerometer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flucasmotta%2Freact-accelerometer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flucasmotta%2Freact-accelerometer/lists"}