Ver código fonte

Details window now aligns again on image load

Taddeus Kroes 12 anos atrás
pai
commit
362f42180e
1 arquivos alterados com 7 adições e 3 exclusões
  1. 7 3
      guide.coffee

+ 7 - 3
guide.coffee

@@ -221,14 +221,18 @@ ProgramDetailsView = Backbone.View.extend(
                     $('#loading-screen').hide()
                     @$el.show()
                     @$('.content').html(@template(_.extend(id: id, data)))
+                    @alignMiddle()
 
-                    # Vertically align in middle
-                    top = @$('.content').outerHeight() / 2
-                    @$('.content').css(marginTop: "-#{top}px")
+                    # Align again after images are loaded
+                    @$('.content img').load(=> @alignMiddle())
             )
         else
             @$el.hide()
             @$('.content').empty()
+
+    alignMiddle: ->
+        top = @$('.content').outerHeight() / 2
+        @$('.content').css(marginTop: "-#{top}px")
 )
 
 AppView = Backbone.View.extend(