|
@@ -11,7 +11,6 @@ class ListViewAdapter {
|
|
|
this.lastContentPosY = 0; // use this variable to detect if we are scrolling up or down
|
|
|
this.spawnCount = 16;
|
|
|
this.itemHeight = 0;
|
|
|
- this.bufferZone = 500;
|
|
|
this.spacing = 10;
|
|
|
this.scriptName = '';
|
|
|
|
|
@@ -19,11 +18,12 @@ class ListViewAdapter {
|
|
|
}
|
|
|
|
|
|
initialize(itemTemplate) {
|
|
|
- // this.bufferZone = this.scrollView.node.height / 2;
|
|
|
+
|
|
|
let actualCount = this.dataList.length < this.spawnCount ? this.dataList.length : this.spawnCount;
|
|
|
// let actualCount = this.dataList.length;
|
|
|
this.scriptItems = [];
|
|
|
if (this.itemHeight > 0) {
|
|
|
+ this.bufferZone = this.scrollView.node.height / 2 + this.content.height / 2;
|
|
|
this.content.height = (this.itemHeight + this.spacing) * this.dataList.length;
|
|
|
}
|
|
|
this.content.removeAllChildren();
|
|
@@ -64,7 +64,7 @@ class ListViewAdapter {
|
|
|
if (isDown) {
|
|
|
// if away from buffer zone and not reaching top of content
|
|
|
if (viewPos.y < -buffer && this.scriptItems[i].node.y + offset < 0) {
|
|
|
- this.scriptItems[i].node.setPositionY(this.scriptItems[i].node.y + offset);
|
|
|
+ this.scriptItems[i].node.y = this.scriptItems[i].node.y + offset;
|
|
|
let itemScript = this.scriptItems[i];
|
|
|
let itemId = itemScript._itemId - this.scriptItems.length;
|
|
|
itemScript.updateItem(this.dataList[itemId], itemId);
|
|
@@ -72,7 +72,7 @@ class ListViewAdapter {
|
|
|
} else {
|
|
|
// if away from buffer zone and not reaching bottom of content
|
|
|
if (viewPos.y > buffer && this.scriptItems[i].node.y - offset > -this.content.height) {
|
|
|
- this.scriptItems[i].node.setPositionY(this.scriptItems[i].node.y - offset);
|
|
|
+ this.scriptItems[i].node.y = this.scriptItems[i].node.y - offset;
|
|
|
|
|
|
let itemScript = this.scriptItems[i];
|
|
|
let itemId = itemScript._itemId + this.scriptItems.length;
|