]> git.proxmox.com Git - extjs.git/blob - extjs/packages/legacy/modern/src/device/Compass.js
add extjs 6.0.1 sources
[extjs.git] / extjs / packages / legacy / modern / src / device / Compass.js
1 /**
2 * Provides access to the native Compass API when running on a device. There are three implementations of this API:
3 *
4 * - [PhoneGap](http://docs.phonegap.com/en/2.6.0/cordova_compass_compass.md.html#Compass)
5 *
6 * This class will automatically select the correct implementation depending on the device your application is running on.
7 *
8 * ## Examples
9 *
10 * Getting the current location:
11 *
12 * Ext.device.Compass.getCurrentHeading({
13 * success: function(heading) {
14 * alert('Heading: ' + heading.magneticHeading);
15 * },
16 * failure: function() {
17 * console.log('something went wrong!');
18 * }
19 * });
20 *
21 * Watching the current compass:
22 *
23 * Ext.device.Compass.watchHeading({
24 * frequency: 500, // Update every 1/2 second
25 * callback: function(heading) {
26 * console.log('Heading: ' + heading.magneticHeading);
27 * },
28 * failure: function() {
29 * console.log('something went wrong!');
30 * }
31 * });
32 *
33 * @mixins Ext.device.compass.Abstract
34 */
35 Ext.define('Ext.device.Compass', {
36 singleton: true,
37
38 requires: [
39 'Ext.device.compass.Cordova',
40 'Ext.device.compass.Simulator'
41 ],
42
43 constructor: function() {
44 var browserEnv = Ext.browser.is;
45 if (browserEnv.WebView && browserEnv.Cordova) {
46 return Ext.create('Ext.device.compass.Cordova');
47 }
48
49 return Ext.create('Ext.device.compass.Simulator');
50 }
51 });