Skip to content

Commit

Permalink
Click outside of canvas to exit webview interaction. Ref GH-1
Browse files Browse the repository at this point in the history
  • Loading branch information
deathcap committed Feb 19, 2014
1 parent bc04310 commit 7b07305
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,24 @@ WebviewPlugin.prototype.enable = function() {
renderWebGL(sceneWebGL);
};
this.originalRender = renderWebGL;

var self = this;

window.addEventListener('click', this.onClick = function(ev) {
// click anywhere outside of iframe to exit TODO: what if it fills the entire screen? (alternate escape hatch)
// (we won't receive click events for the iframe here)
// TODO: register on WebGL canvas element instead?
// tried this.game.view.renderer.domElement but didn't receive events

if (document.getElementById('voxel-webview').parentElement.parentElement.style.zIndex === '0') {
document.getElementById('voxel-webview').parentElement.parentElement.style.zIndex = '-1';
self.game.interact.request();
}
});
};

WebviewPlugin.prototype.disable = function() {
this.game.view.render = this.originalRender;
window.removeEventListener('click', this.onClick);
};

0 comments on commit 7b07305

Please sign in to comment.