summaryrefslogtreecommitdiff
path: root/game
diff options
context:
space:
mode:
authorJustin Worthe <justin.worthe@entelect.co.za>2014-07-31 17:23:39 +0200
committerJustin Worthe <justin.worthe@entelect.co.za>2014-07-31 17:23:39 +0200
commit887de9d0e29b35076ef138a474d5def3a9cb6179 (patch)
tree93a61d2d5558eb36303e2330abfd4f9223ba0c30 /game
parent0a4b32158d6ddd17eb9df21ff5940c736eb8208e (diff)
Fixed semicolon issues
Diffstat (limited to 'game')
-rw-r--r--game/plugins/orientation.js38
1 files changed, 19 insertions, 19 deletions
diff --git a/game/plugins/orientation.js b/game/plugins/orientation.js
index 77ad9fc..af5a649 100644
--- a/game/plugins/orientation.js
+++ b/game/plugins/orientation.js
@@ -13,26 +13,26 @@ var Orientation = function() {
var threshhold = 15;
- var processOrientationEvent = function(event) {
- if (event.gamma < -threshhold && previousEvent.gamma >= -threshhold) {
- this.onLeft.dispatch();
- }
- if (event.gamma > threshhold && previousEvent.gamma <= threshhold) {
- this.onRight.dispatch();
- }
- if (event.beta < -threshhold && previousEvent.beta >= -threshhold) {
- this.onUp.dispatch();
- }
- if (event.beta > threshhold && previousEvent.beta <= threshhold) {
- this.onDown.dispatch();
- }
-
-
- previousEvent = event;
+ if (window.DeviceOrientationEvent) {
+ window.addEventListener('deviceorientation', function(event) {
+ if (event.gamma < -threshhold && previousEvent.gamma >= -threshhold) {
+ this.onLeft.dispatch();
+ }
+ if (event.gamma > threshhold && previousEvent.gamma <= threshhold) {
+ this.onRight.dispatch();
+ }
+ if (event.beta < -threshhold && previousEvent.beta >= -threshhold) {
+ this.onUp.dispatch();
+ }
+ if (event.beta > threshhold && previousEvent.beta <= threshhold) {
+ this.onDown.dispatch();
+ }
+
+ previousEvent.gamma = event.gamma;
+ previousEvent.beta = event.beta;
+ });
}
-
- window.addEventListener('deviceorientation', processOrientationEvent);
-}
+};
module.exports = Orientation;