Skip to content

Commit

Permalink
null orientation fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Willoughby committed Dec 17, 2009
1 parent fa9e0a2 commit f2399be
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions palm/js/orientation.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ function Orientation() {
* @param {Number} orientation The orientation to be set
*/
Orientation.prototype.setOrientation = function(orientation) {
this.currentOrientation = orientation;
var e = document.createEvent('Events');
e.initEvent('orientationChanged', 'false', 'false');
e.orientation = orientation;
document.dispatchEvent(e);
if (!isNaN(orientation) && this.currentOrientation != orientation) {
this.currentOrientation = orientation;
var e = document.createEvent('Events');
e.initEvent('orientationChanged', 'false', 'false');
e.orientation = orientation;
document.dispatchEvent(e);
}
};

/**
Expand All @@ -42,7 +44,7 @@ Orientation.prototype.getCurrentOrientation = function(successCallback, errorCal

if (!this.started)
this.start(successCallback);
else if (this.currentOrientation)
else if (!isNaN(this.currentOrientation))
successCallback(this.currentOrientation);
else
errorCallback();
Expand All @@ -53,7 +55,6 @@ Orientation.prototype.getCurrentOrientation = function(successCallback, errorCal
*/
Orientation.prototype.start = function (successCallback) {
var that = this;

// This subscribes the callback once for the successCallback function
that.callback = function (e) {
Mojo.Event.stopListening(document, "orientationChanged", that.callback);
Expand Down

0 comments on commit f2399be

Please sign in to comment.