Skip to content

Commit

Permalink
fix orientation event bug in DemoMobile
Browse files Browse the repository at this point in the history
  • Loading branch information
liabru committed Jul 2, 2015
1 parent 5b2b060 commit f770a7c
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions demo/js/DemoMobile.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
var _engine,
_sceneName = 'mixed',
_sceneWidth,
_sceneHeight;
_sceneHeight,
_deviceOrientationEvent;

Demo.init = function() {
var canvasContainer = document.getElementById('canvas-container'),
Expand All @@ -44,10 +45,15 @@
}, 800);
});

window.addEventListener('deviceorientation', Demo.updateGravity, true);
window.addEventListener('deviceorientation', function(event) {
_deviceOrientationEvent = event;
Demo.updateGravity(event);
}, true);

window.addEventListener('touchstart', Demo.fullscreen);

window.addEventListener('orientationchange', function() {
Demo.updateGravity();
Demo.updateGravity(_deviceOrientationEvent);
Demo.updateScene();
Demo.fullscreen();
}, false);
Expand Down Expand Up @@ -101,7 +107,7 @@
Demo[_sceneName]();
};

Demo.updateGravity = function () {
Demo.updateGravity = function(event) {
if (!_engine)
return;

Expand Down

0 comments on commit f770a7c

Please sign in to comment.