Skip to content

Instantly share code, notes, and snippets.

@drewcovi
Created August 8, 2015 22:39
Show Gist options
  • Save drewcovi/b79641089eaa52f5d1af to your computer and use it in GitHub Desktop.
Save drewcovi/b79641089eaa52f5d1af to your computer and use it in GitHub Desktop.
/**
@private
@method _reuseChildren
*/
_reuseChildren: function(){
var contentLength, childViews, childViewsLength,
startingIndex, endingIndex, childView, attrs,
contentIndex, visibleEndingIndex, maxContentIndex,
contentIndexEnd, scrollTop, viewsNeededForViewport;
scrollTop = this.scrollTop;
contentLength = get(this, 'content.length');
maxContentIndex = max(contentLength - 1, 0);
childViews = this.getReusableChildViews();
childViewsLength = childViews.length;
viewsNeededForViewport = this._numChildViewsForViewport();
startingIndex = this._startingIndex();
visibleEndingIndex = startingIndex + viewsNeededForViewport;
endingIndex = min(maxContentIndex, visibleEndingIndex);
contentIndexEnd = min(visibleEndingIndex, startingIndex + childViewsLength);
for (contentIndex = startingIndex; contentIndex < contentIndexEnd; contentIndex++) {
if(childViewsLength !== viewsNeededForViewport){
this._syncChildViews()
}
childView = childViews[contentIndex % viewsNeededForViewport];
this._reuseChildForContentIndex(childView, contentIndex);
}
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment