Render more operations when path is collapsed

Previously the command panel would shrink when a path was
collapsed since operations that hadn't been rendered yet weren't
properly added to the DOM.

This removes the collapse/expand animation since it becomes jittery
when combined with rendering new path and operation views.
This commit is contained in:
Kevin Sawicki
2013-04-03 15:42:12 -07:00
parent ec2b116674
commit a762291de9
2 changed files with 25 additions and 20 deletions

View File

@@ -17,9 +17,11 @@ class PathView extends View
initialize: ({@previewList}) ->
@pathDetails.on 'mousedown', => @toggle(true)
@subscribe @previewList, 'command-panel:collapse-result', =>
@collapse(true) if @isSelected()
if @isSelected()
@collapse()
@previewList.renderOperations()
@subscribe @previewList, 'command-panel:expand-result', =>
@expand(true) if @isSelected()
@expand() if @isSelected()
@subscribe @previewList, 'core:confirm', =>
if @hasClass('selected')
@toggle(true)
@@ -36,30 +38,22 @@ class PathView extends View
@previewList.find('.selected').removeClass('selected')
@addClass('selected')
toggle: (animate) ->
toggle: ->
if @hasClass('is-collapsed')
@expand(animate)
@expand()
else
@collapse(animate)
@collapse()
expand: (animate=false) ->
if animate
@matches.show 100, => @removeClass 'is-collapsed'
else
@matches.show()
@removeClass 'is-collapsed'
expand: ->
@matches.show()
@removeClass 'is-collapsed'
scrollTo: ->
top = @previewList.scrollTop() + @offset().top - @previewList.offset().top
bottom = top + @pathDetails.outerHeight()
@previewList.scrollTo(top, bottom)
collapse: (animate=false) ->
if animate
@matches.hide 100, =>
@addClass 'is-collapsed'
@setSelected() if @isSelected()
else
@matches.hide()
@addClass 'is-collapsed'
@setSelected() if @isSelected()
collapse: ->
@matches.hide()
@addClass 'is-collapsed'
@setSelected() if @isSelected()

View File

@@ -43,3 +43,14 @@ describe "Preview List", ->
previousOperationCount = previewList.find("li").length
previewList.collapseAllPaths()
expect(previewList.find("li").length).toBeGreaterThan previousOperationCount
it "renders more operations when a preview item is collapsed", ->
waitsForPromise ->
commandPanelView.execute('X x/so/')
runs ->
expect(previewList.prop('scrollHeight')).toBeGreaterThan previewList.height()
previousScrollHeight = previewList.prop('scrollHeight')
previousOperationCount = previewList.find("li").length
previewList.trigger 'command-panel:collapse-result'
expect(previewList.find("li").length).toBeGreaterThan previousOperationCount