{"id":16994701,"url":"https://github.com/ehzhang/sense-js","last_synced_at":"2025-03-17T09:30:40.661Z","repository":{"id":18804322,"uuid":"22018575","full_name":"ehzhang/sense-js","owner":"ehzhang","description":"📱 html5 sensor interaction library for mobile","archived":false,"fork":false,"pushed_at":"2014-07-25T17:01:02.000Z","size":404,"stargazers_count":226,"open_issues_count":0,"forks_count":21,"subscribers_count":13,"default_branch":"master","last_synced_at":"2024-04-14T12:56:09.679Z","etag":null,"topics":["accelerometer","gyroscope","html5","sensor"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ehzhang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-07-19T20:20:38.000Z","updated_at":"2024-04-13T08:26:38.000Z","dependencies_parsed_at":"2022-09-13T18:12:02.090Z","dependency_job_id":null,"html_url":"https://github.com/ehzhang/sense-js","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ehzhang%2Fsense-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ehzhang%2Fsense-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ehzhang%2Fsense-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ehzhang%2Fsense-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ehzhang","download_url":"https://codeload.github.com/ehzhang/sense-js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243858794,"owners_count":20359257,"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","gyroscope","html5","sensor"],"created_at":"2024-10-14T03:46:18.241Z","updated_at":"2025-03-17T09:30:40.309Z","avatar_url":"https://github.com/ehzhang.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sense.js\n\nan HTML5 interaction library for mobile browsers\n\nOverview\n--------\n\nHTML5 offers a lot of awesome access to hardware data. Sense.js is a library that\nabstracts away the math and gives developers and designers easy access to some\ncommon non-touch gesture interactions with simple javascript callbacks.\n\n### Disclaimer\nThis was made as a part of GreylockU's Hackfest, and will likely see changes to make\nthings better/add more gestures :)\n\nPull requests and feature suggestions are welcome!\n\nDemo\n------\nYou can find a demo at http://sense-js.jit.su/\n\n#### Orientation\nA ball rolls around based on your screen position!\n\n#### Flick\nFlick your phone to the right or left to slide a color.\n\n#### Flip\nFlip your phone face down and face up, and a new color appears!\n\n#### Color Fling\nOpen this page on multiple devices. Selecting a color and flicking it\n'flicks' that color to all other devices.\n\n#### Scroll\nsense.js enabled scroll based on screen tilt\n\n\nQuickstart\n----------\n\nDownload sense.js, and refer to it in an html file, and initialize it!\n\n```html\n\u003cscript src=\"path/to/sense.js\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n    var sense = sense.init();\n    \n    sense.flick(function(data){\n        // Your callback code here!\n    });\n\u003c/script\u003e\n```\n\nDocumentation\n-------------\n\n### sense.orientation([options], callback)\n\nOrientation fires continuously, and emits alpha, beta, and gamma data from the device.\n\nOptions       | Description                              | Default\n------------- | -----------------------------------------|-----------\nalphaThreshold| (number) Threshold for changes in delta  | 0\nbetaThreshold | (number) Threshold for changes in beta   | 0\ngammaThreshold| (number) Threshold for changes in gamma  | 0\nradians       | (boolean) True to emit values in radians | false\n\n\nData          | Description                               \n------------- | -----------------------------------------\nalpha         | (number) degree/radian value for direction the device is pointed \nbeta          | (number) degree/radian value for device's front-back tilt\ngamma         | (number) degree/radian value for device's left-right tilt  \n\nSample Usage:\n```javascript\nsense.orientation(function(data){\n    console.log(data)\n});\n```\n\n### sense.flick([options], callback)\n\nFlick events fire when the device is rotated quickly left-to-right or right-to-left.\n\nOptions       | Description                                                                             | Default\n------------- | ----------------------------------------------------------------------------------------|-----------\ninterval      | (number) the duration in milliseconds to watch for a flick event                        | 150\nsensitivity   | (number) multiplier to adjust amount of acceleration required. lower = more sensitive   | 1 \n\nData          | Description                               \n------------- | -----------------------------------------\ndirection     | (String) 'left' or 'right' depending on the flick direction\nmagnitude     | (number) the magnitude of the acceleration on flick\n\n\nSample Usage:\n```javascript\nsense.flick(function(data){\n    slidePage(data.direction)\n});\n```\n\n### sense.fling([options], callback)\n\nFling events fire when the device is rotated quickly in the front-to-back direction, as if\nbeing thrown overhand (with the device facing towards you).\n\nOptions       | Description                                                                             | Default\n------------- | ----------------------------------------------------------------------------------------|-----------\ninterval      | (number) the duration in milliseconds to watch for a flick event                        | 150\nsensitivity   | (number) multiplier to adjust amount of acceleration required. lower = more sensitive   | 1 \n\nData          | Description                               \n------------- | -----------------------------------------\nmagnitude     | (number) the magnitude of the acceleration on flick\n\n\nSample Usage:\n```javascript\nsense.fling(function(data){\n    sendFile();\n});\n```\n\n### sense.flip([options], callback)\n\nFlip events fire when the phone is quickly flipped from face-up to face-down to face-up position.\n\nOptions         | Description                                                            | Default\n-------------   | -----------------------------------------------------------------------|-----------\ngestureDuration | (number) timespan in milliseconds that the flip event can occur over   | 150\n\nData          | Description                               \n------------- | -----------------------------------------\ngamma         | (number) the final gamma value after the flip\n\n\nSample Usage:\n```javascript\nsense.flip(function(data){\n    showRandomNumber();\n});\n```\n\n### sense.addTiltScroll([options])\n\nThis one line allows the user to observe the tilt of the user's phone to scroll on a page.\n\nOptions             | Description | Default\n--------------------| ------------|------------\nmaxHorizontalAngle  | (number)    | 80\nmaxHorizontalOffset | (number)    | 100\nmaxHorizontalSpeed  | (number)    | 15 \nmaxVerticalAngle    | (number)    | 40\nmaxVerticalOffset   | (number)    | 100\nmaxVerticalSpeed    | (number)    | 15 \n\nSample Usage:\n```javascript\nsense.addTiltScroll();\n```\n\n### Debugging\n\nWe can initialize Sense with a debug flag!\n\n```javascript\nvar sense = sense.init({debug: true});\n```\n\nThe debugger will include a fixed div in the bottom right corner that displays\ndata when events fire. This is particularly useful when debugging on mobile, as you can't\nuse debugger or console.log :(\n\n\nTo start the demo site:\n\n```sh\n$ npm install\n$ npm start\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fehzhang%2Fsense-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fehzhang%2Fsense-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fehzhang%2Fsense-js/lists"}