# HG changeset patch # User Drew Perttula # Date 2016-06-05 02:04:12 # Node ID 2809a8b732f67ed2edd149ca28616a1d01cac505 # Parent 13f758eda3b4998929defc44ddebda3733c197fa optimize graph lookup calls during zoom steps Ignore-this: ab3499a36e5bc2e495fe4abdd2209e35 diff --git a/light9/web/adjustable.coffee b/light9/web/adjustable.coffee --- a/light9/web/adjustable.coffee +++ b/light9/web/adjustable.coffee @@ -97,15 +97,18 @@ class window.AdjustableFloatObject exten # getValueForPos super(@config) - + _getValue: () -> - @config.graph.floatValue(@config.subj, @config.pred) + # 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() continueDrag: (pos) -> diff --git a/light9/web/graph.coffee b/light9/web/graph.coffee --- a/light9/web/graph.coffee +++ b/light9/web/graph.coffee @@ -1,3 +1,5 @@ +log = console.log + # Patch is {addQuads: , delQuads: } # is [{subject: s, ...}, ...] diff --git a/light9/web/timeline.coffee b/light9/web/timeline.coffee --- a/light9/web/timeline.coffee +++ b/light9/web/timeline.coffee @@ -38,22 +38,26 @@ Polymer ko.computed => @debug = ko.toJSON(@viewState) - ko.computed => - @fullZoomX = d3.scaleLinear().domain([0, @viewState.zoomSpec.duration()]).range([0, @width()]) - @zoomInX = d3.scaleLinear().domain([@viewState.zoomSpec.t1(), @viewState.zoomSpec.t2()]).range([0, @width()]) - @dia.setTimeAxis(@width(), @$.zoomed.$.audio.offsetTop, @zoomInX) - @$.adjusters.updateAllCoords() + ko.computed( => + @fullZoomX = d3.scaleLinear().domain([0, @viewState.zoomSpec.duration()]).range([0, @width()]) + @zoomInX = d3.scaleLinear().domain([@viewState.zoomSpec.t1(), @viewState.zoomSpec.t2()]).range([0, @width()]) + @dia.setTimeAxis(@width(), @$.zoomed.$.audio.offsetTop, @zoomInX) + @$.adjusters.updateAllCoords() + ).extend({rateLimit: 5}) - ko.computed => - # zoomInX changing doesn't retrigger this, so I'll do it here - ko.toJS(@viewState.zoomSpec) - - @$.dia.setCursor(@$.audio.offsetTop, @$.audio.offsetHeight, - @$.zoomed.$.time.offsetTop, - @$.zoomed.$.time.offsetHeight, - @fullZoomX, @zoomInX, @viewState.cursor) - - @adjs = @makeZoomAdjs().concat(@persistDemo()) + ko.computed( => + # zoomInX changing doesn't retrigger this, so I'll do it here + ko.toJS(@viewState.zoomSpec) + + @$.dia.setCursor(@$.audio.offsetTop, @$.audio.offsetHeight, + @$.zoomed.$.time.offsetTop, + @$.zoomed.$.time.offsetHeight, + @fullZoomX, @zoomInX, @viewState.cursor) + ) + + setTimeout => + @adjs = @makeZoomAdjs().concat(@persistDemo()) + , 2000 @trackMouse() @bindKeys() @bindWheelZoom()