UNPKG

1.86 kBSource Map (JSON)View Raw
1{"version":3,"file":"ExponentGyroscope.web.js","sourceRoot":"","sources":["../src/ExponentGyroscope.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAE5D,OAAO,EACL,oBAAoB,EACpB,6BAA6B,GAC9B,MAAM,kCAAkC,CAAC;AAE1C,MAAM,SAAS,GAAG,cAAc,CAAC;AAEjC,eAAe;IACb,IAAI,IAAI;QACN,OAAO,mBAAmB,CAAC;IAC7B,CAAC;IACD,KAAK,CAAC,gBAAgB;QACpB,IAAI,OAAO,iBAAiB,KAAK,WAAW,EAAE;YAC5C,OAAO,KAAK,CAAC;SACd;QACD,OAAO,MAAM,oBAAoB,CAAC,SAAS,CAAC,CAAC;IAC/C,CAAC;IACD,aAAa,CAAC,EAAE,4BAA4B,EAAE;QAC5C,wBAAwB,CAAC,IAAI,CAAC,oBAAoB,EAAE;YAClD,CAAC,EAAE,4BAA4B,CAAC,CAAC;YACjC,CAAC,EAAE,4BAA4B,CAAC,CAAC;YACjC,CAAC,EAAE,4BAA4B,CAAC,CAAC;SAClC,CAAC,CAAC;IACL,CAAC;IACD,cAAc;QACZ,6BAA6B,CAAC,SAAS,CAAC,CAAC;QAEzC,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IACzD,CAAC;IACD,aAAa;QACX,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IAC5D,CAAC;CACF,CAAC","sourcesContent":["import { SyntheticPlatformEmitter } from '@unimodules/core';\n\nimport {\n isSensorEnabledAsync,\n assertSensorEventEnabledAsync,\n} from './utils/isSensorEnabledAsync.web';\n\nconst eventName = 'devicemotion';\n\nexport default {\n get name(): string {\n return 'ExponentGyroscope';\n },\n async isAvailableAsync(): Promise<boolean> {\n if (typeof DeviceMotionEvent === 'undefined') {\n return false;\n }\n return await isSensorEnabledAsync(eventName);\n },\n _handleMotion({ accelerationIncludingGravity }) {\n SyntheticPlatformEmitter.emit('gyroscopeDidUpdate', {\n x: accelerationIncludingGravity.x,\n y: accelerationIncludingGravity.y,\n z: accelerationIncludingGravity.z,\n });\n },\n startObserving() {\n assertSensorEventEnabledAsync(eventName);\n\n window.addEventListener(eventName, this._handleMotion);\n },\n stopObserving() {\n window.removeEventListener(eventName, this._handleMotion);\n },\n};\n"]}
\No newline at end of file