Changeset - e82a8a48120c
[Not reviewed]
default
0 2 0
Drew Perttula - 7 years ago 2018-05-27 01:16:49
drewp@bigasterisk.com
update note drawings correctly. rerender less.
Ignore-this: f673b26f919d98b5ee18c1dd94a877f2
2 files changed with 7 insertions and 3 deletions:
0 comments (0 inline, 0 general)
light9/web/timeline/adjusters.coffee
Show inline comments
 
log = console.log
 
Drawing = window.Drawing
 

	
 

	
 
coffeeElementSetup(class AdjustersCanvas extends Polymer.mixinBehaviors([Polymer.IronResizableBehavior], Polymer.Element)
 
  @is: 'light9-adjusters-canvas'
 
  @getter_properties:
 
    setAdjuster: {type: Function, notify: true }
 
  @getter_observers: [
 
    'updateAllCoords(adjs)'
 
  ]
 
  constructor: ->
 
    super()
 
    @redraw = _.throttle(@_throttledRedraw.bind(@), 30, {leading: false})
 
    @redraw = _.throttle(@_throttledRedraw.bind(@), 60, {leading: false})
 
    @adjs = {}
 
    
 
  ready: ->
 
    super.ready()
 
    @addEventListener('iron-resize', @resizeUpdate.bind(@))
 
    @ctx = @$.canvas.getContext('2d')
light9/web/timeline/timeline.coffee
Show inline comments
 
@@ -303,12 +303,13 @@ coffeeElementSetup(class TimeZoomed exte
 

	
 
    @renderer = PIXI.autoDetectRenderer({
 
      backgroundColor: 0x606060,
 
      antialias: true,
 
      forceCanvas: true,
 
    })
 
    @dirty = _.debounce((() => @renderer.render(@stage)), 10)
 

	
 
  ready: ->
 
    super.ready()
 

	
 
    @addEventListener('iron-resize', @_onResize.bind(@))
 
    Polymer.RenderStatus.afterNextRender(this, @_onResize.bind(@))
 
@@ -325,17 +326,20 @@ coffeeElementSetup(class TimeZoomed exte
 
  _onResize: ->
 
    @$.rows.firstChild.style.position = 'relative'
 
    @$.rows.firstChild.style.top = -@viewState.rowsY() + 'px'
 

	
 
    @renderer.resize(@clientWidth, @clientHeight + @viewState.rowsY())
 

	
 
    @renderer.render(@stage)
 
    @dirty()
 

	
 
  _onGraph: (graph, setAdjuster, song, viewState, project)->
 
    return unless @song # polymer will call again
 
    @graph.runHandler(@gatherNotes.bind(@), 'zoom notes')
 

	
 
  noteDirty: ->
 
    @dirty()
 
    
 
  onZoom: ->
 
    updateZoomFlattened = ->
 
      log('updateZoomFlattened')
 
      @zoomFlattened = ko.toJS(@viewState.zoomSpec)
 
    ko.computed(updateZoomFlattened.bind(@))
 
@@ -498,12 +502,13 @@ class Note
 
      @selection.hover(null)
 

	
 
    @graphics = graphics
 
    curveWidthCalc = () => @project.curveWidth(worldPts)
 
    @_updateAdjusters(screenPts, worldPts, curveWidthCalc, yForV, @song)
 
    @_updateInlineAttrs(screenPts)
 
    @parentElem.noteDirty()
 

	
 
  onUri: ->
 
    @graph.runHandler(@update.bind(@), "note updates #{@uri}")
 

	
 
  patchCouldAffectMe: (patch) ->
 
    if patch and patch.addQuads # sometimes patch is a polymer-sent value. @update is used as a listener too
0 comments (0 inline, 0 general)