Changeset - 748a2e8afd30
[Not reviewed]
default
0 1 0
Drew Perttula - 9 years ago 2016-06-09 05:16:32
drewp@bigasterisk.com
rdf graph adjuster, use new runHandler api
Ignore-this: 51fe3a2f2799f473658cc83ed8485ecc
1 file changed with 9 insertions and 3 deletions:
0 comments (0 inline, 0 general)
light9/web/timeline/adjustable.coffee
Show inline comments
 
@@ -90,25 +90,31 @@ class window.AdjustableFloatObject exten
 
    #   pred
 
    #   ctx
 
    #   getTargetTransform(value) -> getTarget result for value
 
    #   getValueForPos
 

	
 
    super(@config)
 
    @config.graph.runHandler(@_syncValue.bind(@))
 

	
 
  _syncValue: () ->
 
    @_currentValue = @config.graph.floatValue(@config.subj, @config.pred)
 
    @_onChange() if @_onChange
 
    
 
  _getValue: () ->
 
    # this is a big speedup- callers use _getValue about 4x as much as
 
    # the graph changes and graph.floatValue is slow
 
    @_currentValue
 

	
 
  getTarget: () ->
 
    @config.getTargetTransform(@_getValue())
 
    
 
  subscribe: (onChange) ->
 
    @config.graph.subscribe @config.subj, @config.pred, null, (patch) =>
 
      @_currentValue = @config.graph.floatValue(@config.subj, @config.pred)
 
      onChange()
 
    # only works on one subscription at a time
 
    throw new Error('multi subscribe not implemented') if @_onChange
 
    @_onChange = onChange
 

	
 
    
 
  continueDrag: (pos) ->
 
    # pos is vec2 of pixels relative to the drag start
 
    
 
    newValue = @config.getValueForPos(@_editorCoordinates())
 
    @config.graph.patchObject(@config.subj, @config.pred,
0 comments (0 inline, 0 general)