From 3972ec42f6a0013098490f3d27df1a500f4edc1f Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Mon, 29 Aug 2016 12:13:01 +0200 Subject: [PATCH] Rename ol.DeviceOrientationProperty to ol.DeviceOrientation.Property --- changelog/upgrade-notes.md | 1 + src/ol/deviceorientation.js | 48 ++++++++++++++++++------------------- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/changelog/upgrade-notes.md b/changelog/upgrade-notes.md index 5aa98e915e..a3b941d9d3 100644 --- a/changelog/upgrade-notes.md +++ b/changelog/upgrade-notes.md @@ -13,6 +13,7 @@ A number of internal types have been renamed. This will not affect those who us * rename `ol.format.IGCZ` to `ol.format.IGC.Z` * rename `ol.layer.GroupProperty` to `ol.layer.Group.Property` * rename `ol.CollectionProperty` to `ol.Collection.Property` + * rename `ol.DeviceOrientationProperty` to `ol.DeviceOrientation.Property` ### v3.18.0 diff --git a/src/ol/deviceorientation.js b/src/ol/deviceorientation.js index be0caf002a..173381da0b 100644 --- a/src/ol/deviceorientation.js +++ b/src/ol/deviceorientation.js @@ -7,18 +7,6 @@ goog.require('ol.has'); goog.require('ol.math'); -/** - * @enum {string} - */ -ol.DeviceOrientationProperty = { - ALPHA: 'alpha', - BETA: 'beta', - GAMMA: 'gamma', - HEADING: 'heading', - TRACKING: 'tracking' -}; - - /** * @classdesc * The ol.DeviceOrientation class provides access to information from @@ -87,7 +75,7 @@ ol.DeviceOrientation = function(opt_options) { this.listenerKey_ = null; ol.events.listen(this, - ol.Object.getChangeEventType(ol.DeviceOrientationProperty.TRACKING), + ol.Object.getChangeEventType(ol.DeviceOrientation.Property.TRACKING), this.handleTrackingChanged_, this); this.setTracking(options.tracking !== undefined ? options.tracking : false); @@ -113,22 +101,22 @@ ol.DeviceOrientation.prototype.orientationChange_ = function(originalEvent) { var event = /** @type {DeviceOrientationEvent} */ (originalEvent); if (event.alpha !== null) { var alpha = ol.math.toRadians(event.alpha); - this.set(ol.DeviceOrientationProperty.ALPHA, alpha); + this.set(ol.DeviceOrientation.Property.ALPHA, alpha); // event.absolute is undefined in iOS. if (typeof event.absolute === 'boolean' && event.absolute) { - this.set(ol.DeviceOrientationProperty.HEADING, alpha); + this.set(ol.DeviceOrientation.Property.HEADING, alpha); } else if (typeof event.webkitCompassHeading === 'number' && event.webkitCompassAccuracy != -1) { var heading = ol.math.toRadians(event.webkitCompassHeading); - this.set(ol.DeviceOrientationProperty.HEADING, heading); + this.set(ol.DeviceOrientation.Property.HEADING, heading); } } if (event.beta !== null) { - this.set(ol.DeviceOrientationProperty.BETA, + this.set(ol.DeviceOrientation.Property.BETA, ol.math.toRadians(event.beta)); } if (event.gamma !== null) { - this.set(ol.DeviceOrientationProperty.GAMMA, + this.set(ol.DeviceOrientation.Property.GAMMA, ol.math.toRadians(event.gamma)); } this.changed(); @@ -144,7 +132,7 @@ ol.DeviceOrientation.prototype.orientationChange_ = function(originalEvent) { */ ol.DeviceOrientation.prototype.getAlpha = function() { return /** @type {number|undefined} */ ( - this.get(ol.DeviceOrientationProperty.ALPHA)); + this.get(ol.DeviceOrientation.Property.ALPHA)); }; @@ -157,7 +145,7 @@ ol.DeviceOrientation.prototype.getAlpha = function() { */ ol.DeviceOrientation.prototype.getBeta = function() { return /** @type {number|undefined} */ ( - this.get(ol.DeviceOrientationProperty.BETA)); + this.get(ol.DeviceOrientation.Property.BETA)); }; @@ -170,7 +158,7 @@ ol.DeviceOrientation.prototype.getBeta = function() { */ ol.DeviceOrientation.prototype.getGamma = function() { return /** @type {number|undefined} */ ( - this.get(ol.DeviceOrientationProperty.GAMMA)); + this.get(ol.DeviceOrientation.Property.GAMMA)); }; @@ -183,7 +171,7 @@ ol.DeviceOrientation.prototype.getGamma = function() { */ ol.DeviceOrientation.prototype.getHeading = function() { return /** @type {number|undefined} */ ( - this.get(ol.DeviceOrientationProperty.HEADING)); + this.get(ol.DeviceOrientation.Property.HEADING)); }; @@ -195,7 +183,7 @@ ol.DeviceOrientation.prototype.getHeading = function() { */ ol.DeviceOrientation.prototype.getTracking = function() { return /** @type {boolean} */ ( - this.get(ol.DeviceOrientationProperty.TRACKING)); + this.get(ol.DeviceOrientation.Property.TRACKING)); }; @@ -224,5 +212,17 @@ ol.DeviceOrientation.prototype.handleTrackingChanged_ = function() { * @api */ ol.DeviceOrientation.prototype.setTracking = function(tracking) { - this.set(ol.DeviceOrientationProperty.TRACKING, tracking); + this.set(ol.DeviceOrientation.Property.TRACKING, tracking); +}; + + +/** + * @enum {string} + */ +ol.DeviceOrientation.Property = { + ALPHA: 'alpha', + BETA: 'beta', + GAMMA: 'gamma', + HEADING: 'heading', + TRACKING: 'tracking' };