From 887de9d0e29b35076ef138a474d5def3a9cb6179 Mon Sep 17 00:00:00 2001 From: Justin Worthe Date: Thu, 31 Jul 2014 17:23:39 +0200 Subject: Fixed semicolon issues --- game/plugins/orientation.js | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'game') 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; -- cgit v1.2.3