changeset 1732:f9593805e109

no more 'listeners' in polymer2. use 'ready' event more. Ignore-this: a32c3be6f48e9b26e3e03b89e67c60fc
author Drew Perttula <drewp@bigasterisk.com>
date Mon, 14 May 2018 02:38:00 +0000
parents e06c2c105035
children 82c6e4f75221
files light9/web/coffee_element.coffee light9/web/timeline/adjusters.coffee light9/web/timeline/cursor_canvas.coffee light9/web/timeline/timeline.coffee
diffstat 4 files changed, 21 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/light9/web/coffee_element.coffee	Mon May 14 02:10:05 2018 +0000
+++ b/light9/web/coffee_element.coffee	Mon May 14 02:38:00 2018 +0000
@@ -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) ->
--- a/light9/web/timeline/adjusters.coffee	Mon May 14 02:10:05 2018 +0000
+++ b/light9/web/timeline/adjusters.coffee	Mon May 14 02:38:00 2018 +0000
@@ -9,10 +9,9 @@
   @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')
 
--- a/light9/web/timeline/cursor_canvas.coffee	Mon May 14 02:10:05 2018 +0000
+++ b/light9/web/timeline/cursor_canvas.coffee	Mon May 14 02:38:00 2018 +0000
@@ -2,21 +2,22 @@
   @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 @@
       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()
 
--- a/light9/web/timeline/timeline.coffee	Mon May 14 02:10:05 2018 +0000
+++ b/light9/web/timeline/timeline.coffee	Mon May 14 02:38:00 2018 +0000
@@ -205,8 +205,8 @@
     '_onSongDuration(songDuration, viewState)',
     '_onSongTime(songTime, viewState)',
   ]
-  connectedCallback: ->
-    super.connectedCallback()
+  ready: ->
+    super.ready()
     
     ko.options.deferUpdates = true;
     
@@ -401,8 +401,8 @@
          backgroundColor: 0xff6060,
     })
      
-  connectedCallback: ->
-    super.connectedCallback()
+  ready: ->
+    super.ready()
      
     @addEventListener('iron-resize', @update.bind(@))
     @update()
@@ -528,7 +528,6 @@
   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 @@
     ]
   ready: ->
     @adjusterIds = {} # id : true
+    @addEventListener('iron-resize', @update)
 
   detached: ->
     log('detatch', @uri)
@@ -702,8 +702,8 @@
   @getter_properties: {
     selection: {type: Object, notify: true}
   }
-  connectedCallback: ->
-    super.connectedCallback()
+  ready: ->
+    super.ready()
     @elemById = {}