Skip to content

Commit

Permalink
handle onvrdisplaydeactivate to exitVR (fixes #2614)
Browse files Browse the repository at this point in the history
  • Loading branch information
ngokevin committed Jun 9, 2017
1 parent 3ba5eda commit c3d6194
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/core/scene/a-scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ module.exports.AScene = registerElement('a-scene', {
});
this.addFullScreenStyles();
initPostMessageAPI(this);

// Handler to exit VR (e.g., Oculus Browser back button).
this.exitVRBound = bind(this.exitVR, this);
window.addEventListener('onvrdisplaydeactivate', this.exitVRBound);
},
writable: true
},
Expand Down Expand Up @@ -131,16 +135,20 @@ module.exports.AScene = registerElement('a-scene', {
*/
detachedCallback: {
value: function () {
var sceneIndex;

if (this.effect && this.effect.cancelAnimationFrame) {
this.effect.cancelAnimationFrame(this.animationFrameID);
} else {
window.cancelAnimationFrame(this.animationFrameID);
}
var sceneIndex;
this.animationFrameID = null;

// Remove from scene index.
sceneIndex = scenes.indexOf(this);
scenes.splice(sceneIndex, 1);

window.removeEventListener('onvrdisplaydeactivate', this.exitVRBound);
}
},

Expand Down

0 comments on commit c3d6194

Please sign in to comment.