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