mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
amend(collectionRepeat): don't render an extra item at the end
Closes #2027
This commit is contained in:
@@ -81,7 +81,7 @@ function($cacheFactory, $parse, $rootScope) {
|
||||
attachItemAtIndex: function(index) {
|
||||
if (index < this.dataStartIndex) {
|
||||
return this.beforeSiblings[index];
|
||||
} else if (index > this.data.length) {
|
||||
} else if (index > this.data.length - 1) {
|
||||
return this.afterSiblings[index - this.data.length - this.dataStartIndex];
|
||||
}
|
||||
|
||||
|
||||
28
js/angular/service/collectionRepeatManager.js
vendored
28
js/angular/service/collectionRepeatManager.js
vendored
@@ -276,27 +276,31 @@ function($rootScope, $timeout) {
|
||||
// Keep rendering items, adding them until we are past the end of the visible scroll area
|
||||
i = renderStartIndex;
|
||||
while ((rect = this.dimensions[i]) && (rect.primaryPos - rect.primarySize < scrollSizeEnd)) {
|
||||
doRender(i++);
|
||||
doRender(i, rect);
|
||||
i++;
|
||||
}
|
||||
|
||||
// Render two extra items at the end as a buffer
|
||||
if (self.dimensions[i]) {
|
||||
doRender(i, self.dimensions[i]);
|
||||
i++;
|
||||
}
|
||||
if (self.dimensions[i]) {
|
||||
doRender(i, self.dimensions[i]);
|
||||
}
|
||||
//Add two more items at the end
|
||||
doRender(i++);
|
||||
doRender(i);
|
||||
var renderEndIndex = i;
|
||||
|
||||
// Remove any items that were rendered and aren't visible anymore
|
||||
for (i in this.renderedItems) {
|
||||
if (i < renderStartIndex || i > renderEndIndex) {
|
||||
this.removeItem(i);
|
||||
for (var renderIndex in this.renderedItems) {
|
||||
if (renderIndex < renderStartIndex || renderIndex > renderEndIndex) {
|
||||
this.removeItem(renderIndex);
|
||||
}
|
||||
}
|
||||
|
||||
this.setCurrentIndex(startIndex);
|
||||
|
||||
function doRender(dataIndex) {
|
||||
var rect = self.dimensions[dataIndex];
|
||||
if (!rect) {
|
||||
|
||||
} else if (dataIndex < self.dataSource.dataStartIndex) {
|
||||
function doRender(dataIndex, rect) {
|
||||
if (dataIndex < self.dataSource.dataStartIndex) {
|
||||
// do nothing
|
||||
} else {
|
||||
self.renderItem(dataIndex, rect.primaryPos - self.beforeSize, rect.secondaryPos);
|
||||
|
||||
Reference in New Issue
Block a user