changeset 1764:aec09f94c030

fix notes drawing themselves after they should be gone Ignore-this: 8ce4b8b194dbc13836d22535de92294d
author drewp@bigasterisk.com
date Thu, 31 May 2018 20:48:43 +0000
parents 9060602f7b3c
children 02222c96d5ff
files light9/web/timeline/timeline.coffee
diffstat 1 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/light9/web/timeline/timeline.coffee	Thu May 31 08:16:20 2018 +0000
+++ b/light9/web/timeline/timeline.coffee	Thu May 31 20:48:43 2018 +0000
@@ -360,8 +360,13 @@
 
     @renderer.render(@stage)
 
+  isActiveNote: (note) ->
+    return @noteByUriStr.has(note.value)
+
   _addNote: (uri, noteNum) ->
     U = (x) => @graph.Uri(x)
+
+    
     con = new PIXI.Container()
     con.interactive=true
     @stage.addChild(con)
@@ -369,7 +374,9 @@
     row = noteNum % 6
     rowTop = @viewState.rowsY() + 20 + 150 * row
     note = new Note(@, con, @project, @graph, @selection, uri, @setAdjuster, U(@song), @viewState, rowTop, rowTop + 140)
+    # this must come before the first Note.draw
     @noteByUriStr.set(uri.value, note)
+    note.initWatchers()
 
   _delNote: (uriStr) ->
     n = @noteByUriStr.get(uriStr)
@@ -436,6 +443,8 @@
 class Note
   constructor: (@parentElem, @container, @project, @graph, @selection, @uri, @setAdjuster, @song, @viewState, @rowTopY, @rowBotY) ->
     @adjusterIds = new Set() # id string
+
+  initWatchers: ->
     @graph.runHandler(@draw.bind(@), "note draw #{@uri.value}")
     ko.computed @draw.bind(@)
 
@@ -460,6 +469,9 @@
     throw new Error("curve #{@uri.value} has no attr #{curveAttr.value}")
 
   draw: ->
+    if not @parentElem.isActiveNote(@uri)
+      # stale redraw call
+      return
     U = (x) => @graph.Uri(x)
     [pointUris, worldPts] = @getCurvePoints(@uri, U(':strength'))
     effect = @graph.uriValue(@uri, U(':effectClass'))