Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

README events example added and orientation naming bug in orientationChange() #64

Merged
merged 3 commits into from
Aug 9, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ For this plugin to follow the full API events should be fired on the screen obje
iOS and BB10 do not currently support events on the _screen_ object so custom event
handling will need to be added (Suggestions welcome!).

### Example usage

window.addEventListener("orientationchange", function(){
console.log('Orientation changed to ' + screen.orientation);
});

## Android Notes

The __screen.orientation__ property will not update when the phone is [rotated 180 degrees](http://www.quirksmode.org/dom/events/orientationchange.html).
Expand Down
6 changes: 4 additions & 2 deletions www/screenorientation.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,13 @@ function addScreenOrientationApi(obj) {
return;
}
screenOrientation.currOrientation = orientation;
screen.orientation = screenOrientation.currOrientation;
screenOrientation.setOrientation(orientation);
};

obj.unlockOrientation = function() {
screenOrientation.currOrientation = 'unlocked';
screen.orientation = screenOrientation.currOrientation;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @elitan

As the screen is passed in you should use obj rather than screen

i.e.

screenOrientation.currOrientation = obj.orientation = orientation;

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not quit sure on what you mean and what changes you want to do. Could you clarify?

(I am rather new to Open Source in general)

screenOrientation.setOrientation('unlocked');
};
}
Expand All @@ -76,13 +78,13 @@ function orientationChange() {
orientation = 'portrait-primary';
break;
case 90:
orientation = 'landscape-secondary';
orientation = 'landscape-primary';
break;
case 180:
orientation = 'portrait-secondary';
break;
case -90:
orientation = 'landscape-primary';
orientation = 'landscape-secondary';
break;
default:
orientation = 'unknown';
Expand Down