{"id":19180166,"url":"https://github.com/hoppula/react-device-events","last_synced_at":"2025-02-23T01:43:18.477Z","repository":{"id":145962301,"uuid":"49580433","full_name":"hoppula/react-device-events","owner":"hoppula","description":"Provides React HoCs for DeviceOrientation \u0026 DeviceMotion events","archived":false,"fork":false,"pushed_at":"2016-01-13T14:58:32.000Z","size":2,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-13T16:50:40.046Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/hoppula.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}},"created_at":"2016-01-13T14:54:57.000Z","updated_at":"2023-03-10T11:03:35.000Z","dependencies_parsed_at":"2023-04-18T04:54:53.878Z","dependency_job_id":null,"html_url":"https://github.com/hoppula/react-device-events","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoppula%2Freact-device-events","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoppula%2Freact-device-events/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoppula%2Freact-device-events/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hoppula%2Freact-device-events/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hoppula","download_url":"https://codeload.github.com/hoppula/react-device-events/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240258178,"owners_count":19772969,"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":[],"created_at":"2024-11-09T10:48:20.774Z","updated_at":"2025-02-23T01:43:18.457Z","avatar_url":"https://github.com/hoppula.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# react-device-events\n\n\u003e Provides React higher order components for [DeviceOrientationEvent](https://developer.mozilla.org/en-US/docs/Web/API/DeviceOrientationEvent) and [DeviceMotionEvent](https://developer.mozilla.org/en-US/docs/Web/API/DeviceMotionEvent)\n\nYour wrapped component gets re-rendered after any `deviceorientation` or `devicemotion` event.\n\n## Installation\n\n`npm install -S react-device-events`\n\n## Usage\n\n### DeviceOrientation\n\n```\nimport React from 'react'\nimport { deviceOrientation } from 'react-device-events'\n\nclass OrientationComponent extends React.Component {\n  render() {\n    const { supported, gamma, beta, alpha, orientation} = this.props.deviceOrientation\n    return (\n      \u003cul\u003e\n        \u003cli\u003e\u003cstrong\u003eSupported:\u003c/strong\u003e {supported ? \"true\" : \"false\"}\u003c/li\u003e\n        \u003cli\u003e\u003cstrong\u003eGamma:\u003c/strong\u003e {gamma}\u003c/li\u003e\n        \u003cli\u003e\u003cstrong\u003eBeta:\u003c/strong\u003e {beta}\u003c/li\u003e\n        \u003cli\u003e\u003cstrong\u003eAlpha:\u003c/strong\u003e {alpha}\u003c/li\u003e\n        \u003cli\u003e\u003cstrong\u003eOrientation:\u003c/strong\u003e {orientation}\u003c/li\u003e\n      \u003c/ul\u003e\n    )\n  }\n}\n\nexport default deviceOrientation(OrientationComponent)\n```\n\n### DeviceMotion\n\n```\nimport React from 'react'\nimport { deviceMotion } from 'react-device-events'\n\nclass MotionComponent extends React.Component {\n  render() {\n    const { supported, acceleration, accelerationIncludingGravity, rotationRate, interval } = this.props.deviceMotion\n    const [accelerationX, accelerationY, accelerationZ] = acceleration || []\n    const [gravityX, gravityY, gravityZ] = accelerationIncludingGravity || []\n    const [alpha, beta, gamma] = rotationRate || []\n    return (\n      \u003cul\u003e\n        \u003cli\u003e\u003cstrong\u003eSupported:\u003c/strong\u003e {supported ? \"true\" : \"false\"}\u003c/li\u003e\n        \u003cli\u003e\u003cstrong\u003eAcceleration:\u003c/strong\u003e {accelerationX} {accelerationY} {accelerationZ}\u003c/li\u003e\n        \u003cli\u003e\u003cstrong\u003eAcceleration including gravity:\u003c/strong\u003e {gravityX} {gravityY} {gravityZ}\u003c/li\u003e\n        \u003cli\u003e\u003cstrong\u003eRotation rate:\u003c/strong\u003e {alpha} {beta} {gamma}\u003c/li\u003e\n        \u003cli\u003e\u003cstrong\u003eInterval:\u003c/strong\u003e {interval}\u003c/li\u003e\n      \u003c/ul\u003e\n    )\n  }\n}\n\nexport default deviceMotion(MotionComponent)\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhoppula%2Freact-device-events","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhoppula%2Freact-device-events","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhoppula%2Freact-device-events/lists"}