[Gutter] Convert GutterContainerComponent::updateChildGutters -> ::reorderGutters

This commit is contained in:
Jess Lin 2015-04-20 22:04:18 -07:00
parent 3051470979
commit 6f66d2fd5d

View File

@ -38,10 +38,11 @@ class GutterContainerComponent
else else
gutterComponent = new CustomGutterComponent({gutter}) gutterComponent = new CustomGutterComponent({gutter})
if visible then gutterComponent.showNode() else gutterComponent.hideNode() if visible then gutterComponent.showNode() else gutterComponent.hideNode()
gutterComponent.updateSync(state)
newGutterComponents.push(gutterComponent) newGutterComponents.push(gutterComponent)
newGutterComponentsByGutterName[gutter.name] = gutterComponent newGutterComponentsByGutterName[gutter.name] = gutterComponent
@updateChildGutters(state, newGutterComponents, newGutterComponentsByGutterName) @reorderGutters(newGutterComponents, newGutterComponentsByGutterName)
@gutterComponents = newGutterComponents @gutterComponents = newGutterComponents
@gutterComponentsByGutterName = newGutterComponentsByGutterName @gutterComponentsByGutterName = newGutterComponentsByGutterName
@ -50,12 +51,12 @@ class GutterContainerComponent
Section: Private Methods Section: Private Methods
### ###
updateChildGutters: (state, newGutterComponents, newGutterComponentsByGutterName) -> reorderGutters: (newGutterComponents, newGutterComponentsByGutterName) ->
# First, insert new gutters into the DOM. # First, insert new gutters into the DOM.
indexInOldGutters = 0 indexInOldGutters = 0
oldGuttersLength = @gutterComponents.length oldGuttersLength = @gutterComponents.length
for gutterComponent in newGutterComponents for gutterComponent in newGutterComponents
gutterComponent.updateSync(state)
if @gutterComponentsByGutterName[gutterComponent.getName()] if @gutterComponentsByGutterName[gutterComponent.getName()]
# If the gutter existed previously, we first try to move the cursor to # If the gutter existed previously, we first try to move the cursor to
# the point at which it occurs in the previous gutters. # the point at which it occurs in the previous gutters.