@@ -140,6 +140,7 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{
140140 _resizeCallback : null ,
141141
142142 _orientationChanging : true ,
143+ _resizing : false ,
143144
144145 _scaleX : 1 ,
145146 _originalScaleX : 1 ,
@@ -187,8 +188,6 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{
187188 _t . _viewName = "Cocos2dHTML5" ;
188189
189190 var sys = cc . sys ;
190- _t . enableRetina ( sys . os === sys . OS_IOS || sys . os === sys . OS_OSX ) ;
191- _t . enableAutoFullScreen ( sys . isMobile && sys . browserType !== sys . BROWSER_TYPE_BAIDU ) ;
192191 cc . visibleRect && cc . visibleRect . init ( _t . _visibleRect ) ;
193192
194193 // Setup system default resolution policies
@@ -212,15 +211,29 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{
212211
213212 // Check frame size changed or not
214213 var prevFrameW = view . _frameSize . width , prevFrameH = view . _frameSize . height , prevRotated = view . _isRotated ;
215- view . _initFrameSize ( ) ;
214+ if ( cc . sys . isMobile ) {
215+ var containerStyle = cc . game . container . style ,
216+ margin = containerStyle . margin ;
217+ containerStyle . margin = '0' ;
218+ containerStyle . display = 'none' ;
219+ view . _initFrameSize ( ) ;
220+ containerStyle . margin = margin ;
221+ containerStyle . display = 'block' ;
222+ }
223+ else {
224+ view . _initFrameSize ( ) ;
225+ }
216226 if ( view . _isRotated === prevRotated && view . _frameSize . width === prevFrameW && view . _frameSize . height === prevFrameH )
217227 return ;
218228
219229 // Frame size changed, do resize works
220230 var width = view . _originalDesignResolutionSize . width ;
221231 var height = view . _originalDesignResolutionSize . height ;
222- if ( width > 0 )
232+ view . _resizing = true ;
233+ if ( width > 0 ) {
223234 view . setDesignResolutionSize ( width , height , view . _resolutionPolicy ) ;
235+ }
236+ view . _resizing = false ;
224237
225238 cc . eventManager . dispatchCustomEvent ( 'canvas-resize' ) ;
226239 if ( view . _resizeCallback ) {
@@ -347,9 +360,11 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{
347360 cc . container . style . transformOrigin = '0px 0px 0px' ;
348361 this . _isRotated = true ;
349362 }
350- setTimeout ( function ( ) {
351- cc . view . _orientationChanging = false ;
352- } , 1000 ) ;
363+ if ( this . _orientationChanging ) {
364+ setTimeout ( function ( ) {
365+ cc . view . _orientationChanging = false ;
366+ } , 1000 ) ;
367+ }
353368 } ,
354369
355370 // hack
@@ -482,12 +497,6 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{
482497 return this . _autoFullScreen ;
483498 } ,
484499
485- /**
486- * Force destroying EGL view, subclass must implement this method.
487- */
488- end : function ( ) {
489- } ,
490-
491500 /**
492501 * Get whether render system is ready(no matter opengl or canvas),<br/>
493502 * this name is for the compatibility with cocos2d-x, subclass must implement this method.
@@ -688,7 +697,8 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{
688697
689698 // Permit to re-detect the orientation of device.
690699 this . _orientationChanging = true ;
691- this . _initFrameSize ( ) ;
700+ if ( ! this . _resizing )
701+ this . _initFrameSize ( ) ;
692702
693703 if ( ! policy ) {
694704 cc . log ( cc . _LogInfos . EGLView_setDesignResolutionSize_2 ) ;
@@ -771,8 +781,10 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{
771781 this . _setViewportMeta ( { "width" : width } , true ) ;
772782
773783 // Set body width to the exact pixel resolution
774- document . documentElement . style . width = width + 'px' ;
775- document . body . style . width = "100%" ;
784+ document . documentElement . style . width = width + "px" ;
785+ document . body . style . width = width + "px" ;
786+ document . body . style . left = "0px" ;
787+ document . body . style . top = "0px" ;
776788
777789 // Reset the resolution size and policy
778790 this . setDesignResolutionSize ( width , height , resolutionPolicy ) ;
@@ -985,7 +997,7 @@ cc.ContainerStrategy = cc.Class.extend(/** @lends cc.ContainerStrategy# */{
985997
986998 _setupContainer : function ( view , w , h ) {
987999 var locCanvas = cc . game . canvas , locContainer = cc . game . container ;
988- if ( cc . sys . isMobile ) {
1000+ if ( cc . sys . os === cc . sys . OS_ANDROID ) {
9891001 document . body . style . width = ( view . _isRotated ? h : w ) + 'px' ;
9901002 document . body . style . height = ( view . _isRotated ? w : h ) + 'px' ;
9911003 }
0 commit comments