Calling collapseAllPaths creates elements for every Dom node

This commit is contained in:
Corey Johnson
2013-03-18 11:55:33 -07:00
committed by probablycorey
parent 10f405f61f
commit 4702f3775d
2 changed files with 16 additions and 2 deletions

View File

@@ -30,6 +30,7 @@ class PreviewList extends ScrollView
@children().each (index, element) -> $(element).view().expand()
collapseAllPaths: ->
@renderOperations(renderAll: true)
@children().each (index, element) -> $(element).view().collapse()
destroy: ->
@@ -46,15 +47,17 @@ class PreviewList extends ScrollView
@show()
@renderOperations()
@find('.operation:first').addClass('selected')
renderOperations: ->
renderOperations: ({renderAll}={}) ->
renderAll ?= false
startingScrollHeight = @prop('scrollHeight')
for operation in @operations[@lastRenderedOperationIndex..]
pathView = @pathViewForPath(operation.getPath())
pathView.addOperation(operation)
@lastRenderedOperationIndex++
break if @prop('scrollHeight') >= startingScrollHeight + @pixelOverdraw and @prop('scrollHeight') > @height() + @pixelOverdraw
break if not renderAll and @prop('scrollHeight') >= startingScrollHeight + @pixelOverdraw and @prop('scrollHeight') > @height() + @pixelOverdraw
pathViewForPath: (path) ->
pathView = @viewsForPath[path]

View File

@@ -32,3 +32,14 @@ describe "Preview List", ->
previewList.trigger('scroll') # Not sure why scroll event isn't being triggered on it's own
expect(previewList.prop('scrollHeight')).toBeGreaterThan previousScrollHeight
expect(previewList.find("li").length).toBeGreaterThan previousOperationCount
it "renders all operations if the preview items are 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.collapseAllPaths()
expect(previewList.find("li").length).toBeGreaterThan previousOperationCount