Gallery: orientation image showing issue has been fixed
authorhjnim.kim <hjnim.kim@samsung.com>
Wed, 10 Apr 2013 10:38:32 +0000 (19:38 +0900)
committerYoumin Ha <youmin.ha@samsung.com>
Wed, 10 Apr 2013 14:57:33 +0000 (23:57 +0900)
Orientation image showing issue has been fixed
N_SE-33296

Change-Id: Ie02e29a0e87929d311b28c4e9a1c9e301ada0f31

src/js/widgets/jquery.mobile.tizen.gallery.js

index 08674e4..c03fcee 100644 (file)
@@ -163,6 +163,7 @@ define( [ ], function ( ) {
                align_type: null,
                direction: 1,
                container: null,
+               orientationEventFire: false,
 
                _resize: function ( index ) {
                        var img = this.images[index],
@@ -592,8 +593,20 @@ define( [ ], function ( ) {
 
                        this.align_type = $( this.element ).jqmData( 'vertical-align' );
 
-                       $( window ).bind( 'resize', function () {
-                               self.refresh();
+                       $.extend( this, {
+                               _globalHandlers: [
+                                       {
+                                               src: $( window ),
+                                               handler: {
+                                                       orientationchange: $.proxy( this, "_orientationHandler" ),
+                                                       resize: $.proxy( this, "_resizeHandler" )
+                                               }
+                                       }
+                               ]
+                       });
+
+                       $.each( this._globalHandlers, function( idx, value ) {
+                               value.src.bind( value.handler );
                        });
                },
 
@@ -615,7 +628,18 @@ define( [ ], function ( ) {
 
                        this._detach_all();
                },
-
+               _resizeHandler: function() {
+                       var self = this;
+                       if( self.orientationEventFire ) {
+                               self.refresh();
+                               self.orientationEventFire = false;
+                       }
+               },
+               _orientationHandler: function() {
+                       var self = this;
+                       self.refresh();
+                       self.orientationEventFire = true;
+               },
                refresh: function ( start_index ) {
                        this._update();
 
@@ -720,7 +744,13 @@ define( [ ], function ( ) {
                        }
 
                        this.refresh( index );
+               },
+
+               destory: function() {
+                       $( window ).unbind( 'resize', this._resizeHandler );
+                       $( window ).unbind( 'orientationchange' , this._orientationHandler );
                }
+
        }); /* End of widget */
 
        // auto self-init widgets