Changeset - 5f9d22f9c85b
[Not reviewed]
default
0 2 0
drewp@bigasterisk.com - 7 years ago 2018-06-01 01:39:40
drewp@bigasterisk.com
fix adjuster-drag coordinate bug. highlight nearby adj.
Ignore-this: 169a65c9b2932d453a630ee8d68fc1cf
2 files changed with 17 insertions and 8 deletions:
0 comments (0 inline, 0 general)
light9/web/timeline/adjusters.coffee
Show inline comments
 
@@ -14,6 +14,7 @@ coffeeElementSetup(class AdjustersCanvas
 
    super()
 
    @redraw = _.throttle(@_throttledRedraw.bind(@), 30, {leading: false})
 
    @adjs = {}
 
    @hoveringNear = null
 
    
 
  ready: ->
 
    super.ready()
 
@@ -28,9 +29,12 @@ coffeeElementSetup(class AdjustersCanvas
 
    @addEventListener('mousemove', @onMove.bind(@))
 
    @addEventListener('mouseup', @onUp.bind(@))
 
   
 
  _mousePos: (ev) ->
 
    $V([ev.clientX, ev.clientY - @offsetParent.offsetTop])
 
  
 
  onDown: (ev) ->
 
    if ev.buttons == 1
 
      start = $V([ev.x, ev.y])
 
      start = @_mousePos(ev)
 
      adj = @_adjAtPoint(start)
 
      if adj
 
        ev.stopPropagation()
 
@@ -38,11 +42,17 @@ coffeeElementSetup(class AdjustersCanvas
 
        adj.startDrag()
 

	
 
  onMove: (ev) ->
 
    pos = $V([ev.x, ev.y])
 
    pos = @_mousePos(ev)
 
    if @currentDrag
 
      @hoveringNear = null
 
      @currentDrag.cur = pos
 
      @currentDrag.adj.continueDrag(
 
        @currentDrag.cur.subtract(@currentDrag.start))
 
    else
 
      near = @_adjAtPoint(pos)
 
      if @hoveringNear != near
 
        @hoveringNear = near
 
        @redraw()
 

	
 
  onUp: (ev) ->
 
    return unless @currentDrag
 
@@ -71,8 +81,6 @@ coffeeElementSetup(class AdjustersCanvas
 

	
 
  _adjAtPoint: (pt) ->
 
    nearest = @qt.find(pt.e(1), pt.e(2))
 
    if nearest?
 
      log('near', nearest.distanceFrom(pt))
 
    if not nearest? or nearest.distanceFrom(pt) > maxDist
 
      return null
 
    return nearest?.adj
 
@@ -99,7 +107,8 @@ coffeeElementSetup(class AdjustersCanvas
 
      
 
      @_drawAdjuster(adj.getDisplayValue(),
 
                     ctr.e(1) - 20, ctr.e(2) - 10,
 
                     ctr.e(1) + 20, ctr.e(2) + 10)
 
                     ctr.e(1) + 20, ctr.e(2) + 10,
 
                     adj == @hoveringNear)
 
    console.timeEnd('adjs redraw')
 

	
 
  _layoutCenters: ->
 
@@ -152,7 +161,7 @@ coffeeElementSetup(class AdjustersCanvas
 
    Drawing.line(@ctx, ctr, target)
 
    @ctx.stroke()
 
    
 
  _drawAdjuster: (label, x1, y1, x2, y2) ->
 
  _drawAdjuster: (label, x1, y1, x2, y2, hover) ->
 
    radius = 8
 

	
 
    @ctx.shadowColor = 'black'
 
@@ -160,7 +169,7 @@ coffeeElementSetup(class AdjustersCanvas
 
    @ctx.shadowOffsetX = 5
 
    @ctx.shadowOffsetY = 9
 
    
 
    @ctx.fillStyle = 'rgba(255, 255, 0, 0.5)'
 
    @ctx.fillStyle = if hover then '#ffff88' else 'rgba(255, 255, 0, 0.5)'
 
    @ctx.beginPath()
 
    Drawing.roundRect(@ctx, x1, y1, x2, y2, radius)
 
    @ctx.fill()
light9/web/timeline/viewstate.coffee
Show inline comments
 
@@ -38,7 +38,7 @@ class window.ViewState
 
    if @zoomSpec.duration() and @zoomSpec.t2() > @zoomSpec.duration()
 
      @zoomSpec.t2(@zoomSpec.duration())
 

	
 
    rightPad = 2 # don't let time adjuster fall off right edge
 
    rightPad = 5 # don't let time adjuster fall off right edge
 
    @fullZoomX.domain([0, @zoomSpec.duration()])
 
    @fullZoomX.range([0, @width() - rightPad])
 

	
0 comments (0 inline, 0 general)