Browse Source

去掉setPositionY的相关方法调用

hwt 6 years ago
parent
commit
dd066fede5

+ 3 - 3
allstarSubGame/assets/Script/ListViewAdapter.js

@@ -24,7 +24,7 @@ class ListViewAdapter {
         // let actualCount = this.dataList.length;
         this.scriptItems = [];
         this.content.removeAllChildren();
-        for (let i = 0; i < actualCount; ++i) { // spawn items, we only need to do this once
+        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
@@ -59,7 +59,7 @@ class ListViewAdapter {
             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.setPositionY(this.scriptItems[i].y + offset);
+                    this.scriptItems[i].node.y = this.scriptItems[i].y + offset;
                     let itemScript = this.scriptItems[i];
                     let itemId = itemScript._itemId - this.scriptItems.length;
                     itemScript.updateItem(this.dataList[itemId], itemId);
@@ -67,7 +67,7 @@ class ListViewAdapter {
             } 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.setPositionY(this.scriptItems[i].y - offset);
+                    this.scriptItems[i].node.y = this.scriptItems[i].y - offset;
 
                     let itemScript = this.scriptItems[i];
                     let itemId = itemScript._itemId + scriptItems.length;

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

@@ -137,7 +137,7 @@ cc.Class({
                 openIdList: ['selfOpenId'],
                 success: (userRes) => {
                     console.log('success', userRes.data)
-                    let userData = userRes.data[0];
+                    let myData = userRes.data[0];
                     //取出所有好友数据
                     wx.getFriendCloudStorage({
                         keyList: [key1],
@@ -159,6 +159,12 @@ cc.Class({
                                 return b_score - a_score;
                             });
 
+                            for (let i = 0; i < data.length; i++) {
+                                if (user.avatarUrl == myData.avatarUrl) {
+                                    data.splice(i, 1);
+                                }
+                            }
+
                             this.users = data;
 
                             this.listAdapter.updateItems(this.users, this.prefabRankItem, 'WechatFriendListItem');

+ 7 - 7
assets/resources/prefabs/rank_page.prefab

@@ -882,7 +882,7 @@
     },
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 182,
+      "width": 180,
       "height": 40
     },
     "_rotationX": 0,
@@ -1152,7 +1152,7 @@
     },
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 182,
+      "width": 180,
       "height": 40
     },
     "_rotationX": 0,
@@ -2100,7 +2100,7 @@
     },
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 94,
+      "width": 90,
       "height": 40
     },
     "_rotationX": 0,
@@ -2478,7 +2478,7 @@
     },
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 44,
+      "width": 40,
       "height": 30
     },
     "_rotationX": 0,
@@ -3396,7 +3396,7 @@
     },
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 94,
+      "width": 90,
       "height": 40
     },
     "_rotationX": 0,
@@ -3859,7 +3859,7 @@
     },
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 48,
+      "width": 44,
       "height": 30
     },
     "_rotationX": 0,
@@ -3966,7 +3966,7 @@
     },
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 17,
+      "width": 13,
       "height": 40
     },
     "_rotationX": 0,

+ 4 - 4
assets/scripts/friendlist/ListViewAdapter.js

@@ -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;