changeset 1330:17aa66cb6248

support page width updates Ignore-this: ead3ce33f47bc1f962cc219571422ebe
author Drew Perttula <drewp@bigasterisk.com>
date Sat, 04 Jun 2016 08:04:32 +0000
parents 44558087d3f6
children 14b8e874e89b
files light9/web/timeline.coffee
diffstat 1 files changed, 10 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/light9/web/timeline.coffee	Sat Jun 04 08:04:01 2016 +0000
+++ b/light9/web/timeline.coffee	Sat Jun 04 08:04:32 2016 +0000
@@ -7,7 +7,12 @@
     viewState: { type: Object }
     debug: {type: String}
     graph: {type: Object, notify: true}
-    
+  width: ko.observable(1)
+  listeners:
+    'iron-resize': '_onIronResize'
+  _onIronResize: ->
+    @width(@offsetWidth)
+
   attached: ->
     @dia = @$.dia
     @viewState =
@@ -22,9 +27,8 @@
       @debug = ko.toJSON(@viewState)
 
     ko.computed =>
-      # todo: need to trigger this when @offsetWidth changes, too
-      @fullZoomX = d3.scaleLinear().domain([0, @viewState.zoomSpec.duration()]).range([0, @offsetWidth])
-      @zoomInX = d3.scaleLinear().domain([@viewState.zoomSpec.t1(), @viewState.zoomSpec.t2()]).range([0, @offsetWidth])
+      @fullZoomX = d3.scaleLinear().domain([0, @viewState.zoomSpec.duration()]).range([0, @width()])
+      @zoomInX = d3.scaleLinear().domain([@viewState.zoomSpec.t1(), @viewState.zoomSpec.t2()]).range([0, @width()])
       @$.adjusters.updateAllCoords()
 
     animCursor = () => 
@@ -38,9 +42,8 @@
       
     setInterval(animCursor, 50)
 
-    setTimeout(() =>
-      @adjs = @makeZoomAdjs().concat(@persistDemo())
-    , 500)
+    @adjs = @makeZoomAdjs().concat(@persistDemo())
+
 
   persistDemo: ->
     ctx = @graph.Uri('http://example.com/')