{ "version": "0.2.6", "name": "org.apache.cordova.device-motion", "cordova_name": "Device Motion", "description": "Cordova Device Motion Plugin", "license": "Apache 2.0", "repo": "https://git-wip-us.apache.org/repos/asf/cordova-plugin-device-motion.git", "issue": "https://issues.apache.org/jira/browse/CB/component/12320636", "keywords": [ "cordova", "device", "motion" ], "platforms": [ "firefoxos", "android", "amazon-fireos", "ubuntu", "ios", "blackberry10", "wp7", "wp8", "windows8", "tizen" ], "engines": [], "englishdoc": "\n\n# org.apache.cordova.device-motion\n\nThis plugin provides access to the device's accelerometer. The accelerometer is\na motion sensor that detects the change (_delta_) in movement relative to the\ncurrent device orientation, in three dimensions along the _x_, _y_, and _z_\naxis.\n\n## Installation\n\n cordova plugin add org.apache.cordova.device-motion\n\n## Supported Platforms\n\n- Amazon Fire OS\n- Android\n- BlackBerry 10\n- iOS\n- Tizen\n- Windows Phone 7 and 8\n- Windows 8\n\n## Methods\n\n- navigator.accelerometer.getCurrentAcceleration\n- navigator.accelerometer.watchAcceleration\n- navigator.accelerometer.clearWatch\n\n## Objects\n\n- Acceleration\n\n## navigator.accelerometer.getCurrentAcceleration\n\nGet the current acceleration along the _x_, _y_, and _z_ axes.\n\nThese acceleration values are returned to the `accelerometerSuccess`\ncallback function.\n\n navigator.accelerometer.getCurrentAcceleration(accelerometerSuccess, accelerometerError);\n\n\n### Example\n\n function onSuccess(acceleration) {\n alert('Acceleration X: ' + acceleration.x + '\\n' +\n 'Acceleration Y: ' + acceleration.y + '\\n' +\n 'Acceleration Z: ' + acceleration.z + '\\n' +\n 'Timestamp: ' + acceleration.timestamp + '\\n');\n };\n\n function onError() {\n alert('onError!');\n };\n\n navigator.accelerometer.getCurrentAcceleration(onSuccess, onError);\n\n### iOS Quirks\n\n- iOS doesn't recognize the concept of getting the current acceleration at any given point.\n\n- You must watch the acceleration and capture the data at given time intervals.\n\n- Thus, the `getCurrentAcceleration` function yields the last value reported from a `watchAccelerometer` call.\n\n## navigator.accelerometer.watchAcceleration\n\nRetrieves the device's current `Acceleration` at a regular interval, executing\nthe `accelerometerSuccess` callback function each time. Specify the interval in\nmilliseconds via the `acceleratorOptions` object's `frequency` parameter.\n\nThe returned watch ID references the accelerometer's watch interval,\nand can be used with `navigator.accelerometer.clearWatch` to stop watching the\naccelerometer.\n\n var watchID = navigator.accelerometer.watchAcceleration(accelerometerSuccess,\n accelerometerError,\n [accelerometerOptions]);\n\n- __accelerometerOptions__: An object with the following optional keys:\n - __frequency__: How often to retrieve the `Acceleration` in milliseconds. _(Number)_ (Default: 10000)\n\n\n### Example\n\n function onSuccess(acceleration) {\n alert('Acceleration X: ' + acceleration.x + '\\n' +\n 'Acceleration Y: ' + acceleration.y + '\\n' +\n 'Acceleration Z: ' + acceleration.z + '\\n' +\n 'Timestamp: ' + acceleration.timestamp + '\\n');\n };\n\n function onError() {\n alert('onError!');\n };\n\n var options = { frequency: 3000 }; // Update every 3 seconds\n\n var watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, options);\n\n### iOS Quirks\n\nThe API calls the success callback function at the interval requested,\nbut restricts the range of requests to the device between 40ms and\n1000ms. For example, if you request an interval of 3 seconds,\n(3000ms), the API requests data from the device every 1 second, but\nonly executes the success callback every 3 seconds.\n\n## navigator.accelerometer.clearWatch\n\nStop watching the `Acceleration` referenced by the `watchID` parameter.\n\n navigator.accelerometer.clearWatch(watchID);\n\n- __watchID__: The ID returned by `navigator.accelerometer.watchAcceleration`.\n\n### Example\n\n var watchID = navigator.accelerometer.watchAcceleration(onSuccess, onError, options);\n\n // ... later on ...\n\n navigator.accelerometer.clearWatch(watchID);\n\n## Acceleration\n\nContains `Accelerometer` data captured at a specific point in time.\nAcceleration values include the effect of gravity (9.81 m/s^2), so that when a\ndevice lies flat and facing up, _x_, _y_, and _z_ values returned should be\n`0`, `0`, and `9.81`.\n\n### Properties\n\n- __x__: Amount of acceleration on the x-axis. (in m/s^2) _(Number)_\n- __y__: Amount of acceleration on the y-axis. (in m/s^2) _(Number)_\n- __z__: Amount of acceleration on the z-axis. (in m/s^2) _(Number)_\n- __timestamp__: Creation timestamp in milliseconds. _(DOMTimeStamp)_\n\n" }