From 120f99ee79fe37feab6401290526298bf7834951 Mon Sep 17 00:00:00 2001 From: Andrew Date: Wed, 20 Aug 2014 11:21:22 -0600 Subject: [PATCH] fix(collectionRepeat): always render data correctly with before/after isblings Closes #2025 --- js/angular/service/collectionRepeatDataSource.js | 9 +++++++-- js/angular/service/collectionRepeatManager.js | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/js/angular/service/collectionRepeatDataSource.js b/js/angular/service/collectionRepeatDataSource.js index 4ab917ac1c4..f10ca42d131 100644 --- a/js/angular/service/collectionRepeatDataSource.js +++ b/js/angular/service/collectionRepeatDataSource.js @@ -81,8 +81,13 @@ function($cacheFactory, $parse, $rootScope) { attachItemAtIndex: function(index) { if (index < this.dataStartIndex) { return this.beforeSiblings[index]; - } else if (index > this.data.length - 1) { - return this.afterSiblings[index - this.data.length - this.dataStartIndex]; + } + // Subtract so we start at the beginning of this.data, after + // this.beforeSiblings. + index -= this.dataStartIndex; + + if (index > this.data.length - 1) { + return this.afterSiblings[index - this.dataStartIndex]; } var item = this.getItem(index); diff --git a/js/angular/service/collectionRepeatManager.js b/js/angular/service/collectionRepeatManager.js index baca432183e..fccc3fb9bda 100644 --- a/js/angular/service/collectionRepeatManager.js +++ b/js/angular/service/collectionRepeatManager.js @@ -106,7 +106,6 @@ function($rootScope, $timeout) { primaryPos = secondaryPos = 0; previousItem = null; - var dimensions = this.dataSource.dimensions.map(calculateSize, this); var totalSize = primaryPos + (previousItem ? previousItem.primarySize : 0); @@ -310,6 +309,7 @@ function($rootScope, $timeout) { renderItem: function(dataIndex, primaryPos, secondaryPos) { // Attach an item, and set its transform position to the required value var item = this.dataSource.attachItemAtIndex(dataIndex); + console.log(dataIndex, item); if (item && item.element) { if (item.primaryPos !== primaryPos || item.secondaryPos !== secondaryPos) { item.element.css(ionic.CSS.TRANSFORM, this.transformString(