diff --git a/src/ol/deviceorientation.js b/src/ol/deviceorientation.js index 4c1397f7d1..ac08dbd56c 100644 --- a/src/ol/deviceorientation.js +++ b/src/ol/deviceorientation.js @@ -208,10 +208,10 @@ ol.DeviceOrientation.prototype.getTracking = function() { ol.DeviceOrientation.prototype.handleTrackingChanged_ = function() { if (ol.has.DEVICE_ORIENTATION) { var tracking = this.getTracking(); - if (tracking && goog.isNull(this.listenerKey_)) { + if (tracking && !this.listenerKey_) { this.listenerKey_ = goog.events.listen(goog.global, 'deviceorientation', this.orientationChange_, false, this); - } else if (!tracking && !goog.isNull(this.listenerKey_)) { + } else if (!tracking && this.listenerKey_) { goog.events.unlistenByKey(this.listenerKey_); this.listenerKey_ = null; }