mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-01-19 00:12:53 +08:00
Removed gyroscope - unmaintained
This commit is contained in:
parent
11b059932b
commit
fbfefec33b
@ -1,108 +0,0 @@
|
||||
import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core';
|
||||
import { Observable } from 'rxjs';
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
declare const navigator: any;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
export interface GyroscopeOrientation {
|
||||
/**
|
||||
* Represent x-axis
|
||||
*/
|
||||
x: number;
|
||||
|
||||
/**
|
||||
* Represent y-axis
|
||||
*/
|
||||
y: number;
|
||||
|
||||
/**
|
||||
* Represent z-axis
|
||||
*/
|
||||
z: number;
|
||||
|
||||
/**
|
||||
* Represent timestamp of sensor read. Default is 10000ms
|
||||
*/
|
||||
timestamp: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
export interface GyroscopeOptions {
|
||||
/**
|
||||
* Represent how often (in milliseconds) sensor should be read. Default is 10000 ms
|
||||
*/
|
||||
frequency: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* @name Gyroscope
|
||||
* @description Read Gyroscope sensor data
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { Gyroscope, GyroscopeOrientation, GyroscopeOptions } from '@ionic-native/gyroscope/ngx';
|
||||
*
|
||||
*
|
||||
* constructor(private gyroscope: Gyroscope) { }
|
||||
*
|
||||
* ...
|
||||
*
|
||||
*
|
||||
* let options: GyroscopeOptions = {
|
||||
* frequency: 1000
|
||||
* }
|
||||
*
|
||||
* this.gyroscope.getCurrent(options)
|
||||
* .then((orientation: GyroscopeOrientation) => {
|
||||
* console.log(orientation.x, orientation.y, orientation.z, orientation.timestamp);
|
||||
* })
|
||||
* .catch()
|
||||
*
|
||||
*
|
||||
* this.gyroscope.watch()
|
||||
* .subscribe((orientation: GyroscopeOrientation) => {
|
||||
* console.log(orientation.x, orientation.y, orientation.z, orientation.timestamp);
|
||||
* });
|
||||
*
|
||||
* ```
|
||||
* @interfaces
|
||||
* GyroscopeOrientation
|
||||
* GyroscopeOptions
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'Gyroscope',
|
||||
plugin: 'cordova-plugin-gyroscope',
|
||||
pluginRef: 'navigator.gyroscope',
|
||||
repo: 'https://github.com/NeoLSN/cordova-plugin-gyroscope',
|
||||
platforms: ['Android', 'iOS'],
|
||||
})
|
||||
@Injectable()
|
||||
export class Gyroscope extends IonicNativePlugin {
|
||||
/**
|
||||
* Watching for gyroscope sensor changes
|
||||
* @param {GyroscopeOptions} [options]
|
||||
* @return {Observable<GyroscopeOrientation>} Returns an Observable that resolves GyroscopeOrientation
|
||||
*/
|
||||
watch(options?: GyroscopeOptions): Observable<GyroscopeOrientation> {
|
||||
return new Observable<GyroscopeOrientation>((observer: any) => {
|
||||
const watchId = navigator.gyroscope.watch(observer.next.bind(observer), observer.next.bind(observer), options);
|
||||
return () => navigator.gyroscope.clearWatch(watchId);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current data from gyroscope sensor
|
||||
* @param {GyroscopeOptions} [options]
|
||||
* @return {Promise<GyroscopeOrientation>} Returns a promise that resolves GyroscopeOrientation
|
||||
*/
|
||||
@Cordova({
|
||||
callbackOrder: 'reverse',
|
||||
})
|
||||
getCurrent(options?: GyroscopeOptions): Promise<GyroscopeOrientation> {
|
||||
return;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user