{"id":15489366,"url":"https://github.com/methodswithclass/accelerometer","last_synced_at":"2025-04-22T18:20:36.396Z","repository":{"id":56415776,"uuid":"107448208","full_name":"methodswithclass/accelerometer","owner":"methodswithclass","description":"An engine that reads the accelerometer data from the device, calculates position, and applies it to a DOM element.","archived":false,"fork":false,"pushed_at":"2023-08-20T15:23:45.000Z","size":580,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-16T00:07:50.912Z","etag":null,"topics":["acceleration","accelerometer","calculation","dynamics","gaming","integration","math","motion","numerical","physics","velocity"],"latest_commit_sha":null,"homepage":"","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/methodswithclass.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}},"created_at":"2017-10-18T18:37:33.000Z","updated_at":"2023-08-13T16:49:53.000Z","dependencies_parsed_at":"2022-08-15T18:20:16.845Z","dependency_job_id":"bf9c173e-4b78-461c-ac23-6880d6e899fb","html_url":"https://github.com/methodswithclass/accelerometer","commit_stats":{"total_commits":66,"total_committers":3,"mean_commits":22.0,"dds":0.303030303030303,"last_synced_commit":"2b0158979448fc9886704006900fe93a609b5be9"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/methodswithclass%2Faccelerometer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/methodswithclass%2Faccelerometer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/methodswithclass%2Faccelerometer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/methodswithclass%2Faccelerometer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/methodswithclass","download_url":"https://codeload.github.com/methodswithclass/accelerometer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250296455,"owners_count":21407037,"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":["acceleration","accelerometer","calculation","dynamics","gaming","integration","math","motion","numerical","physics","velocity"],"created_at":"2024-10-02T07:05:10.931Z","updated_at":"2025-04-22T18:20:36.365Z","avatar_url":"https://github.com/methodswithclass.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Accelerometer\n\nThis package takes acceleromter data from your device, calculates position, and applies it to a DOM element.\nApplications inlcude gaming, user interface controls, and more.\n\n# Change log\n\nVersion 3.3.0: request device motion permission bug fix\n\n# Usage\n\nIt numerically integrates the velocity and position, in real time, from the accelerometer data from the device.\n\n`npm install @methodswithclass/accelerometer`\n\n`import Accelerometer, { ValidStatus } from @methodswithclass/accelerometer`\n\none of these values is returned in a promise from accel.validate()\n\n```\nValidStatus = {\n\tvalid: 'valid',\n\tinvalid: 'invalid',\n\tunchecked: 'unchecked',\n\tdenied: 'denied',\n\tunresponsive: 'unresponsive',\n}\n```\n\nparameters for numerical integration process and general motion behavior, defaults are shown\n\n```\nconst params = {\n\tinterval: 2, //acceleromter interval in milliseconds\n\tfilterSize: 3, //sampling/smoothing size\n\tmu: 0.1, //friction\n\tdamp: 0.4, //bounce dampening\n\tgravity: true, //whether the object responds to tilting of device (true) or only change in position of device (false)\n\tbounce: true, //whether the object bounces off walls (true), or sticks to the wall (false)\n\ttimeout: 10, // motion timeout with no activity, in seconds\n\txDir: 1, //horizonal flip\n\tyDir: 1, //vertical flip\n\tfactor: 0.008, //sensitivity factor (speed of object)\n}\n```\n\nAccelerometer manages several instances by id, subsequent calls return original\n\n```\nconst accel = Accelerometer({\n\tid: \"accel\", // name of accelerometer instance\n\tarena: \"arenaId\", // element id to space to move within\n\tobject: \"objectId\", //element id of object to be moved\n\tparams, //inject accelerometer parameters\n\toverrideValidate: false // not all devices have accelerometers, this flag forces the validator to return 'valid', for local development\n});\n\naccel.calibrate({ xDir, yDir, factor}); // this is run by default\n\naccel.validate(); // returns a promise with the device validation status, requests permission if necessary (must prompt with a button to request permission)\n\naccel.start(); //start updating position of DOM element based on accelerometer data\n\naccel.stop(); // stop updating position, reset\n\naccel.reset(); // returns object to initial position\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmethodswithclass%2Faccelerometer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmethodswithclass%2Faccelerometer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmethodswithclass%2Faccelerometer/lists"}