@@ -217,13 +217,14 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{
217
217
return ;
218
218
219
219
// Frame size changed, do resize works
220
- if ( view . _resizeCallback ) {
221
- view . _resizeCallback . call ( ) ;
222
- }
223
220
var width = view . _originalDesignResolutionSize . width ;
224
221
var height = view . _originalDesignResolutionSize . height ;
225
- if ( width > 0 ) {
222
+ if ( width > 0 )
226
223
view . setDesignResolutionSize ( width , height , view . _resolutionPolicy ) ;
224
+
225
+ cc . eventManager . dispatchCustomEvent ( 'canvas-resize' ) ;
226
+ if ( view . _resizeCallback ) {
227
+ view . _resizeCallback . call ( ) ;
227
228
}
228
229
} ,
229
230
@@ -287,7 +288,7 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{
287
288
* @param {Function|null } callback The callback function
288
289
*/
289
290
setResizeCallback : function ( callback ) {
290
- if ( cc . isFunction ( callback ) || callback == null ) {
291
+ if ( typeof callback === 'function' || callback == null ) {
291
292
this . _resizeCallback = callback ;
292
293
}
293
294
} ,
@@ -304,6 +305,9 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{
304
305
orientation = orientation & cc . ORIENTATION_AUTO ;
305
306
if ( orientation ) {
306
307
this . _orientation = orientation ;
308
+ var designWidth = this . _originalDesignResolutionSize . width ;
309
+ var designHeight = this . _originalDesignResolutionSize . height ;
310
+ this . setDesignResolutionSize ( designWidth , designHeight , this . _resolutionPolicy ) ;
307
311
}
308
312
} ,
309
313
@@ -428,7 +432,7 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{
428
432
* @param {Boolean } enabled Enable or disable retina display
429
433
*/
430
434
enableRetina : function ( enabled ) {
431
- this . _retinaEnabled = enabled ? true : false ;
435
+ this . _retinaEnabled = ! ! enabled ;
432
436
} ,
433
437
434
438
/**
@@ -672,6 +676,8 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{
672
676
if ( cc . sys . isMobile )
673
677
this . _adjustViewportMeta ( ) ;
674
678
679
+ // Permit to re-detect the orientation of device.
680
+ this . _orientationChanging = true ;
675
681
this . _initFrameSize ( ) ;
676
682
677
683
this . _originalDesignResolutionSize . width = this . _designResolutionSize . width = width ;
@@ -713,6 +719,9 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{
713
719
// reset director's member variables to fit visible rect
714
720
director . setGLDefaultValues ( ) ;
715
721
}
722
+ else if ( cc . _renderType === cc . game . RENDER_TYPE_CANVAS ) {
723
+ cc . renderer . _allNeedDraw = true ;
724
+ }
716
725
717
726
this . _originalScaleX = this . _scaleX ;
718
727
this . _originalScaleY = this . _scaleY ;
@@ -747,7 +756,7 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{
747
756
*/
748
757
setRealPixelResolution : function ( width , height , resolutionPolicy ) {
749
758
// Set viewport's width
750
- this . _setViewportMeta ( { "width" : width , "target-densitydpi" : cc . DENSITYDPI_DEVICE } , true ) ;
759
+ this . _setViewportMeta ( { "width" : width } , true ) ;
751
760
752
761
// Set body width to the exact pixel resolution
753
762
document . body . style . width = width + "px" ;
@@ -871,10 +880,10 @@ cc.EGLView = cc.Class.extend(/** @lends cc.view# */{
871
880
return this . _isRotated ? { x : this . _viewPortRect . width - y , y : x } : { x : x , y : y } ;
872
881
} ,
873
882
874
- _convertMouseToLocationInView : function ( point , relatedPos ) {
875
- var locViewPortRect = this . _viewPortRect , _t = this ;
876
- point . x = ( ( _t . _devicePixelRatio * ( point . x - relatedPos . left ) ) - locViewPortRect . x ) / _t . _scaleX ;
877
- point . y = ( _t . _devicePixelRatio * ( relatedPos . top + relatedPos . height - point . y ) - locViewPortRect . y ) / _t . _scaleY ;
883
+ _convertMouseToLocationInView : function ( point , relatedPos ) {
884
+ var viewport = this . _viewPortRect , _t = this ;
885
+ point . x = ( ( _t . _devicePixelRatio * ( point . x - relatedPos . left ) ) - viewport . x ) / _t . _scaleX ;
886
+ point . y = ( _t . _devicePixelRatio * ( relatedPos . top + relatedPos . height - point . y ) - viewport . y ) / _t . _scaleY ;
878
887
} ,
879
888
880
889
_convertPointWithScale : function ( point ) {
@@ -945,6 +954,10 @@ cc.ContainerStrategy = cc.Class.extend(/** @lends cc.ContainerStrategy# */{
945
954
946
955
_setupContainer : function ( view , w , h ) {
947
956
var locCanvas = cc . game . canvas , locContainer = cc . game . container ;
957
+ if ( cc . sys . os === cc . sys . OS_ANDROID ) {
958
+ document . body . style . width = ( view . _isRotated ? h : w ) + 'px' ;
959
+ document . body . style . height = ( view . _isRotated ? w : h ) + 'px' ;
960
+ }
948
961
949
962
// Setup style
950
963
locContainer . style . width = locCanvas . style . width = w + 'px' ;
0 commit comments