changeset 1765:02222c96d5ff

fix mouseout event on notes Ignore-this: b9dbe5f77b9e100c15e2c65516643149
author drewp@bigasterisk.com
date Thu, 31 May 2018 22:59:43 +0000
parents aec09f94c030
children 5f9d22f9c85b
files light9/web/timeline/timeline.coffee
diffstat 1 files changed, 20 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/light9/web/timeline/timeline.coffee	Thu May 31 20:48:43 2018 +0000
+++ b/light9/web/timeline/timeline.coffee	Thu May 31 22:59:43 2018 +0000
@@ -485,11 +485,11 @@
     @graphics.interactive = true
     @container.addChild(@graphics)
 
+    if @uri.equals(@selection.hover())
+      @_traceBorder(screenPts, 12, 0x888888)
     @selection.selected().forEach (s) =>
       if s.equals(@uri)
-        @_traceBorder(screenPts, 8, 0xff2900)
-    if @uri.equals(@selection.hover())
-      @_traceBorder(screenPts, 6, 0x888888)
+        @_traceBorder(screenPts, 6, 0xff2900)
 
     shape = new PIXI.Polygon(screenPts)
     @graphics.beginFill(@_noteColor(effect), .313)
@@ -498,17 +498,7 @@
 
     @_traceBorder(screenPts, 2, 0xffd900)
 
-    @graphics.on 'mousedown', (ev) =>
-      log('down gfx', @uri.value)
-      @_onMouseDown(ev)
-
-    @graphics.on 'mouseover', =>
-      log('hover', @uri.value)
-      @selection.hover(@uri)
-
-    @graphics.on 'mouseout', =>
-      log('hoverout', @uri.value)
-      @selection.hover(null)
+    @_addMouseBindings()
 
     curveWidthCalc = () => @project.curveWidth(worldPts)
     @_updateAdjusters(screenPts, worldPts, curveWidthCalc, yForV, @song)
@@ -521,6 +511,22 @@
     for p in screenPts.slice(1)
       @graphics.lineTo(p.x, p.y)
 
+  _addMouseBindings: () ->
+    @graphics.on 'mousedown', (ev) =>
+      @_onMouseDown(ev)
+
+    @graphics.on 'mouseover', =>
+      if @selection.hover() and @selection.hover().equals(@uri)
+        # Hovering causes a redraw, which would cause another
+        # mouseover event.
+        return
+      @selection.hover(@uri)
+
+    # mouseout never fires since we rebuild the graphics on mouseover.
+    @graphics.on 'mousemove', (ev) =>
+      if @selection.hover() and @selection.hover().equals(@uri) and ev.target != @graphics
+        @selection.hover(null)
+
   onUri: ->
     @graph.runHandler(@update.bind(@), "note updates #{@uri}")