Skip to content

Fixed #3841: Use event on cc.canvas to make full screen request #1518

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jan 25, 2014
5 changes: 3 additions & 2 deletions cocos2d/core/platform/CCScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,15 @@ cc.Screen = cc.Class.extend({
*/
autoFullScreen: function (element, onFullScreenChange) {
element = element || document.body;
var touchTarget = cc.canvas || element;
var theScreen = this;
// Function bind will be too complicated here because we need the callback function's reference to remove the listener
function callback() {
theScreen.requestFullScreen(element, onFullScreenChange);
element.removeEventListener(theScreen._touchEvent, callback);
touchTarget.removeEventListener(theScreen._touchEvent, callback);
}
this.requestFullScreen(element, onFullScreenChange);
element.addEventListener(this._touchEvent, callback);
touchTarget.addEventListener(this._touchEvent, callback);
}
});

Expand Down