hwt 6 yıl önce
ebeveyn
işleme
13471a956d

+ 9 - 4
allstarSubGame/assets/Script/ListViewAdapter.js

@@ -22,12 +22,17 @@ class ListViewAdapter {
         console.log(this.scriptName);
         let actualCount = this.dataList.length < this.spawnCount ? this.dataList.length : this.spawnCount;
         // let actualCount = this.dataList.length;
+        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.scriptItems = [];
         this.content.removeAllChildren();
         for (let i = 0; i < actualCount; i++) { // spawn items, we only need to do this once
             let item = cc.instantiate(itemTemplate);
             if (this.itemHeight === 0) {
                 this.itemHeight = item.height; // get total content height
+                this.bufferZone = this.scrollView.node.height / 2 + this.content.height / 2;
                 this.content.height = (this.itemHeight + this.spacing) * this.dataList.length;
             }
             this.content.addChild(item);
@@ -58,16 +63,16 @@ class ListViewAdapter {
             let viewPos = this.getPositionInView(this.scriptItems[i].node);
             if (isDown) {
                 // if away from buffer zone and not reaching top of content
-                if (viewPos.y < -buffer && this.scriptItems[i].y + offset < 0) {
-                    this.scriptItems[i].node.y = this.scriptItems[i].y + offset;
+                if (viewPos.y < -buffer && this.scriptItems[i].node.y + offset < 0) {
+                    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);
                 }
             } else {
                 // if away from buffer zone and not reaching bottom of content
-                if (viewPos.y > buffer && this.scriptItems[i].y - offset > -this.content.height) {
-                    this.scriptItems[i].node.y = this.scriptItems[i].y - offset;
+                if (viewPos.y > buffer && this.scriptItems[i].node.y - offset > -this.content.height) {
+                    this.scriptItems[i].node.y = this.scriptItems[i].node.y - offset;
 
                     let itemScript = this.scriptItems[i];
                     let itemId = itemScript._itemId + scriptItems.length;

+ 1 - 1
allstarSubGame/assets/Script/WechatFriendList.js

@@ -160,7 +160,7 @@ cc.Class({
                             });
 
                             for (let i = 0; i < data.length; i++) {
-                                if (user.avatarUrl == myData.avatarUrl) {
+                                if (data[i].avatarUrl == myData.avatarUrl) {
                                     data.splice(i, 1);
                                 }
                             }

+ 2 - 1
assets/scripts/friendlist/ListViewAdapter.js

@@ -21,16 +21,17 @@ class ListViewAdapter {
 
         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.scriptItems = [];
         this.content.removeAllChildren();
         for (let i = 0; i < actualCount; ++i) { // spawn items, we only need to do this once
             let item = cc.instantiate(itemTemplate);
             if (this.itemHeight === 0) {
                 this.itemHeight = item.height; // get total content height
+                this.bufferZone = this.scrollView.node.height / 2 + this.content.height / 2;
                 this.content.height = (this.itemHeight + this.spacing) * this.dataList.length;
             }
             this.content.addChild(item);

+ 3 - 1
assets/scripts/rank/RankListWithAdapter.js

@@ -52,6 +52,8 @@ cc.Class({
     },
 
     onScrollEvent() {
-        this.listAdapter.update();
+        if (this.listAdapter) {
+            this.listAdapter.update();
+        }
     },
 });