Răsfoiți Sursa

Page now centers on indicator when loaded

Taddeus Kroes 12 ani în urmă
părinte
comite
6be5b093b7
1 a modificat fișierele cu 5 adăugiri și 2 ștergeri
  1. 5 2
      guide.coffee

+ 5 - 2
guide.coffee

@@ -5,7 +5,7 @@
 #FETCH_URL = 'http://www.tvgids.nl/json/lists/programs.php'
 #FETCH_URL = 'http://www.tvgids.nl/json/lists/programs.php'
 FETCH_URL = 'programs.php'
 FETCH_URL = 'programs.php'
 HOUR_WIDTH = 200
 HOUR_WIDTH = 200
-SCROLL_MULTIPLIER = HOUR_WIDTH
+#SCROLL_MULTIPLIER = HOUR_WIDTH
 
 
 #
 #
 # Utils
 # Utils
@@ -47,7 +47,6 @@ ChannelList = Backbone.Collection.extend(
 
 
     initialize: (models, options) ->
     initialize: (models, options) ->
         #_.each(CHANNELS, (props, id) => @add(_.extend({id: id}, props)))
         #_.each(CHANNELS, (props, id) => @add(_.extend({id: id}, props)))
-
         @fetchVisible()
         @fetchVisible()
         #@fetchPrograms(0)
         #@fetchPrograms(0)
 
 
@@ -155,6 +154,7 @@ AppView = Backbone.View.extend(
 
 
     initialize: ->
     initialize: ->
         @updateIndicator()
         @updateIndicator()
+        @centerIndicator()
         @listenTo(Channels, 'reset', @addChannels)
         @listenTo(Channels, 'reset', @addChannels)
 
 
         Channels.fetch()
         Channels.fetch()
@@ -180,6 +180,9 @@ AppView = Backbone.View.extend(
     updateIndicator: ->
     updateIndicator: ->
         @$('.indicator').css('left', time2px(seconds_today(Date.now())) + 'px')
         @$('.indicator').css('left', time2px(seconds_today(Date.now())) + 'px')
 
 
+    centerIndicator: ->
+        @el.scrollLeft = @$('.indicator').position().left - @$el.width() / 2
+
     fetchPrograms: ->
     fetchPrograms: ->
         Channels.fetchPrograms(Settings.get('day'))
         Channels.fetchPrograms(Settings.get('day'))
 )
 )