diff --git a/light9/web/coffee_element.coffee b/light9/web/coffee_element.coffee --- a/light9/web/coffee_element.coffee +++ b/light9/web/coffee_element.coffee @@ -1,5 +1,5 @@ # Polymer seems to need static getters for 'observers' and -# 'listeners', not just static attributes, though I don't know how it +# 'properties', not just static attributes, though I don't know how it # can even tell the difference. # # This workaround is to use names like '@getter_properties' in the @@ -7,7 +7,7 @@ # # Also see http://coffeescript.org/#unsupported-get-set window.coffeeElementSetup = (cls) -> - for attr in ['properties', 'observers', 'listeners'] + for attr in ['properties', 'observers'] val = cls['getter_' + attr] if val? do (val) -> diff --git a/light9/web/timeline/adjusters.coffee b/light9/web/timeline/adjusters.coffee --- a/light9/web/timeline/adjusters.coffee +++ b/light9/web/timeline/adjusters.coffee @@ -9,10 +9,9 @@ coffeeElementSetup(class AdjustersCanvas @getter_observers: [ 'updateAllCoords(adjs)' ] - @getter_listeners: - 'iron-resize': 'resizeUpdate' - connectedCallback: -> - super.connectedCallback() + ready: -> + super.ready() + @addEventListener('iron-resize', @resizeUpdate.bind(@)) @adjs = {} @ctx = @$.canvas.getContext('2d') diff --git a/light9/web/timeline/cursor_canvas.coffee b/light9/web/timeline/cursor_canvas.coffee --- a/light9/web/timeline/cursor_canvas.coffee +++ b/light9/web/timeline/cursor_canvas.coffee @@ -2,21 +2,22 @@ coffeeElementSetup(class CursorCanvas ex @is: 'light9-cursor-canvas' @getter_properties: viewState: { type: Object, notify: true, observer: "onViewState" } - @getter_listeners: 'iron-resize': 'update' - connectedCallback: -> - super.connectedCallback() + ready: -> + super.ready() @mouseX = 0 @mouseY = 0 @cursorPath = null @ctx = @$.canvas.getContext('2d') + @onResize() + @addEventListener('iron-resize', @onResize.bind(@)) onViewState: -> ko.computed(@redrawCursor.bind(@)) - update: (ev) -> - @$.canvas.width = ev.target.offsetWidth - @$.canvas.height = ev.target.offsetHeight - @redraw() + onResize: (ev) -> + @$.canvas.width = @offsetWidth + @$.canvas.height = @offsetHeight + @redrawCursor() redrawCursor: -> vs = @viewState @@ -32,7 +33,7 @@ coffeeElementSetup(class CursorCanvas ex mid2: $V([xZoomedOut - 1, vs.audioY() + vs.audioH()]) mid3: $V([xZoomedOut + 1, vs.audioY() + vs.audioH()]) bot0: $V([xZoomedIn, vs.zoomedTimeY() + vs.zoomedTimeH()]) - bot1: $V([xZoomedIn, @offsetParent.offsetHeight]) + bot1: $V([xZoomedIn, @offsetHeight]) } @redraw() diff --git a/light9/web/timeline/timeline.coffee b/light9/web/timeline/timeline.coffee --- a/light9/web/timeline/timeline.coffee +++ b/light9/web/timeline/timeline.coffee @@ -205,8 +205,8 @@ coffeeElementSetup(class TimelineEditor '_onSongDuration(songDuration, viewState)', '_onSongTime(songTime, viewState)', ] - connectedCallback: -> - super.connectedCallback() + ready: -> + super.ready() ko.options.deferUpdates = true; @@ -401,8 +401,8 @@ coffeeElementSetup(class TimeZoomed exte backgroundColor: 0xff6060, }) - connectedCallback: -> - super.connectedCallback() + ready: -> + super.ready() @addEventListener('iron-resize', @update.bind(@)) @update() @@ -528,7 +528,6 @@ class Note constructor: (@graph, @selection, @dia, @uri, @setAdjuster, @song, @zoomInX)->0 @is: 'light9-timeline-note' @behaviors: [ Polymer.IronResizableBehavior ] - @listeners: 'iron-resize': 'update' #move to parent elem @properties: graph: { type: Object, notify: true } selection: { type: Object, notify: true } @@ -544,6 +543,7 @@ class Note ] ready: -> @adjusterIds = {} # id : true + @addEventListener('iron-resize', @update) detached: -> log('detatch', @uri) @@ -702,8 +702,8 @@ coffeeElementSetup(class DiagramLayer ex @getter_properties: { selection: {type: Object, notify: true} } - connectedCallback: -> - super.connectedCallback() + ready: -> + super.ready() @elemById = {}