# HG changeset patch # User Drew Perttula # Date 1465196839 0 # Node ID a6ca5e87ab3e289c0ce35cf93fb028f726613217 # Parent b7023c28dd4f772b7cc63721361ad5f693a308e5 a bit more usage of runHandler in timeline element Ignore-this: 7f8b7ddd8c7501b8231755c4a172ad2c diff -r b7023c28dd4f -r a6ca5e87ab3e light9/web/light9-timeline-audio.html --- a/light9/web/light9-timeline-audio.html Mon Jun 06 06:45:01 2016 +0000 +++ b/light9/web/light9-timeline-audio.html Mon Jun 06 07:07:19 2016 +0000 @@ -30,37 +30,39 @@ Polymer({ is: "light9-timeline-audio", properties: { - graph: {type: Object, notify: true, observer: '_imgSrc'}, - show: {type: String, notify: true, observer: '_imgSrc'}, - song: {type: String, notify: true, observer: '_imgSrc'}, // song + graph: {type: Object, notify: true}, + show: {type: String, notify: true}, + song: {type: String, notify: true}, zoom: {type: Object, notify: true}, imgSrc: { type: String, notify: true}, imgWidth: { computed: '_imgWidth(zoom)' }, imgLeft: { computed: '_imgLeft(zoom)' }, }, + observers: [ + 'setImgSrc(graph, show, song)' + ], ready: function() { this.zoom = {duration: 0}; - }, - - _imgSrc: function() { - try { - // Should be subscriptions to root and filename - // that get replaced when the song changes. - if (this.graph && this.show && !this.subscribed) { - this.subscribed = true; - this.graph.subscribe(this.graph.Uri(this.show), null, null, - this._imgSrc.bind(this)); + }, + setImgSrc: function() { + graph.runHandler(function() { + try { + var root = this.graph.stringValue( + this.graph.Uri(this.show), + this.graph.Uri(':spectrogramUrlRoot')); + } catch(e) { + return; } - var root = this.graph.stringValue( - this.graph.Uri(this.show), - this.graph.Uri(':spectrogramUrlRoot')); - var filename = this.graph.stringValue( - this.song, this.graph.Uri(':songFilename')); + try { + var filename = this.graph.stringValue( + this.song, this.graph.Uri(':songFilename')); + } catch(e) { + return; + } + this.imgSrc = root + '/' + filename.replace('.wav', '.png'); - } catch(e) { - log(e) - } + }.bind(this)); }, _imgWidth: function(zoom) { if (!zoom.duration) { diff -r b7023c28dd4f -r a6ca5e87ab3e light9/web/timeline-elements.html --- a/light9/web/timeline-elements.html Mon Jun 06 06:45:01 2016 +0000 +++ b/light9/web/timeline-elements.html Mon Jun 06 07:07:19 2016 +0000 @@ -96,7 +96,9 @@ diff -r b7023c28dd4f -r a6ca5e87ab3e light9/web/timeline.coffee --- a/light9/web/timeline.coffee Mon Jun 06 06:45:01 2016 +0000 +++ b/light9/web/timeline.coffee Mon Jun 06 07:07:19 2016 +0000 @@ -187,9 +187,18 @@ graph: { type: Object, notify: true } zoomInX: { type: Object, notify: true } noteUris: { type: Array, notify: true } - ready: -> + rowIndex: { type: Object, notify: true } + observers: [ + 'onGraph(graph, zoomInX)' + ] + onGraph: -> + @graph.runHandler(@update.bind(@)) + update: -> + U = (x) -> @graph.Uri(x) + @noteUris = [] - @push('noteUris', 'http://light9.bigasterisk.com/show/dance2016/song1/n1') + for note in @graph.objects(@song, U(':note')) + @push('noteUris', note) Polymer @@ -199,9 +208,10 @@ properties: graph: { type: Object, notify: true } uri: { type: String, notify: true } - zoomInX: { type: Object, notify: true, observer: 'update' } + zoomInX: { type: Object, notify: true } observers: [ 'onUri(graph, uri)' + 'update(graph, uri, zoomInX)' ] ready: -> @@ -232,7 +242,7 @@ setNote(@uri, (screenPos(pt) for pt in worldPts)) catch e - log('during resize, ', e) + log("during resize of #{@uri}: #{@e}") Polymer is: "light9-timeline-adjusters" @@ -251,7 +261,7 @@ graph.runHandler(@update.bind(@)) update: (parentAdjs, graph, song, dia) -> U = (x) -> @graph.Uri(x) - @adjs = @parentAdjs.slice() + @adjs = (@parentAdjs || []).slice() for note in @graph.objects(@song, U(':note')) @push('adjs', new AdjustableFloatObject({ graph: @graph