ListView.js
82.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
//TODO:
//焦点框可以跟随滑块移动(只修改翻页部分)、行滚动时焦点框问题、焦点向下滚动时添加了回调,避免连续点击焦点框错乱
//nodeCell初始化为active=false,铺数据改为true,解决空数据时初始后的nodeCell一闪而过的问题。-2.0版本
var Common = require('Common');
var Network = require('Network');
var TVFocus = require('TVFocus');
var FocusInfo = require('FocusInfo');
var Application = require('Application');
var TVCanvas = require('TVCanvas');
var ListCell = require('ListCell');
var TVScrollParameter = require('TVScrollParameter');
cc.Class({
extends: cc.Component,
properties: {
_iShowCellRows: 10, //显示的行数
_iAlphaCellRows: 1, //不可聚焦的半透明行数
_iHiddeCellRows: 10, //隐藏的行数 一般等于显示的行数
_iCellCountEachRow: 1,
_iCellRowCount: 21, //一般等于隐藏的加显示的总数
_iRecordIndexOfFirstCellInPage: 0, //当前页的第一个记录索引值
_iRecordCount: 0,//由数据请求来决定
_iPFBIndexOfFirstCellInPage: 0,
//Cell形状相关
_iTitleDirection: 1, //铺设相关 0-总体横向向右 1-总体纵向向下
_iSwitchDirection: 1, //滑动相关 0-横向 2-纵向 暂时认为滚动条和滑动方向一致
_fCellStartX: 0,
_fCellStartY: 0,
_fCellMarginTop: 1,
_fCellMarginRight: 0,
_fCellMarginBottom: 0,
_fCellMarginLeft: 0,
_compSceneCanvas: null,
_oDataSource: { default: {} },
_iStatusInScene: 0, //组件在Canvas里的焦点分配STATUS
_fFocusScaleFactor: 1,
_fnDataDecorator: null,
_fnDataPositionRender: null,
_strListCellName: "",
},
init: function (compSceneCanvas, iShowCellRows, iAlphaCellRows, iHiddenCellRows, iCellCountEachRow,
/*strDataContainerMaskNodeName,strDataContainerNodeName,*/strListCellComponentName,
fCellStartX, fCellStartY,
fCellMarginTop, fCellMarginRight, fCellMarginBottom, fCellMarginLeft,
iTitleDirection, iSwitchDirection, //0-横向滑动 1-纵向滑动
onInit
) {
this.compListCell = require(strListCellComponentName);//todo:这里的改动感觉还是不大好,List View是公共部分,要注意作用域的问题,如果直接在init里面let的话,担心以后其他地方用的改组件,所以直接把改组件require成为listview的一个成员函数
this._strListCellName = this.compListCell.CELL_NAME || "ListCell";
this._compSceneCanvas = compSceneCanvas;
this._iShowCellRows = iShowCellRows;
this._iAlphaCellRows = iAlphaCellRows;
this._iHiddenCellRows = iHiddenCellRows;
this._iCellCountEachRow = iCellCountEachRow;
this._iCellRowCount = this._iShowCellRows + this._iAlphaCellRows + this._iHiddenCellRows; //以后任何 有修改都要引起他更新
this._fCellStartX = fCellStartX;
this._fCellStartY = fCellStartY;
this._fCellMarginTop = fCellMarginTop;
this._fCellMarginRight = fCellMarginRight;
this._fCellMarginBottom = fCellMarginBottom;
this._fCellMarginLeft = fCellMarginLeft;
this._iTitleDirection = iTitleDirection;
this._iSwitchDirection = iSwitchDirection;
this.node.getChildByName('DataContainerMask').getChildByName('DataContainer').addComponent(TVScrollParameter);
//this.strDataContainerNodeName=
//this._nodeDataContainer=this.node.getChildByName(strDataContainerMaskNodeName).getChildByName(strDataContainerNodeName);
//网络请求相关的 数据源参数
//this._oDataSource={};
this._oDataSource.method = '';
this._oDataSource.url = '';
this._oDataSource.parameters = {};
this._oDataSource.start = 0;
this._oDataSource.limit = 0;
this._oDataSource.sortField = '';
this._oDataSource.sortDirection = '';
if (null == this._fnDataDecorator || typeof (this._fnDataDecorator) != 'function') {
this._fnDataDecorator = function (aData, onDecorate, oScope) {
if (oScope) {
if (null != oScope) {
onDecorate.call(oScope, aData);
} else {
onDecorate(aData);
}
}
}
}
//this.node.getChildByName('ScrollBarContainer').getChildByName('ScrollBarBlock').addComponent(FocusInfo);
Common.loadRes(this.compListCell.PFB_NAME,
function (loadedResource) {
for (let i = 0; i < this._iCellRowCount * this._iCellCountEachRow; i++) {
let nodeCell = cc.instantiate(loadedResource);
//cc.log("Loading PFB "+strListCellComponentName);
let compCell = nodeCell.addComponent(this.compListCell);
//排列细胞
if (1 == this._iTitleDirection) { //纵向排列默认
// 1 2
// 3 4
// 5 6
nodeCell.x = this._fCellStartX + (i % this._iCellCountEachRow)
* (this._fCellMarginLeft + nodeCell.width + this._fCellMarginRight);
nodeCell.y = this._fCellStartY - Math.floor(i / this._iCellCountEachRow)
* (this._fCellMarginTop + nodeCell.height + this._fCellMarginBottom);
} else {
// 1 3 5
// 2 4 6
nodeCell.x = this._fCellStartX + Math.floor(i / this._iCellCountEachRow)
* (this._iCellMarginLeft + nodeCell.width + this._fCellMarginRight);
nodeCell.y = this._fCellStartY - (i % this._iCellCountEachRow)
* (this._fCellMarginTop + nodeCell.height + this._fCellMarginBottom);
}
//let lc=nodeStarListCell.getComponent(StarCell);
nodeCell.zIndex = 10;
//Connect it to parent
this.node.getChildByName('DataContainerMask')
.getChildByName('DataContainer')
//.addChild(nodeCell,10,"ListCell"+i);
.addChild(nodeCell, 10, this._strListCellName + i);//todo:都叫ListCell是否要考虑一个场景出现多个列表用到此ListView组件,名字这块是否个性化,
//Init the Cell
if (i < this._iShowCellRows) {
compCell.init(i, true, this._compSceneCanvas);
} else if (i < this._iShowCellRows + this._iAlphaCellRows) {
compCell.init(i, false, this._compSceneCanvas);
} else {
compCell.init(i, false, this._compSceneCanvas);
}
//-------------2.0版本------------
nodeCell.active = false;
//---------------------------------
}
//callBack
if (null != compSceneCanvas && null != onInit) {
onInit.call(compSceneCanvas);
} else {
onInit();
}
},
function (error) {
cc.log("Error When Loading Prefab Cell...");
}, this
);
},
setCellMargin: function (fMarginTop, fMarginRight, fMarginBottom, fMarginLeft) {
this._iCellMarginTop = fMarginTop;
this._iCellMarginRight = fMarginRight;
this._iCellMarginBottom = fMarginBottom;
this._iCellMarginLeft = fMarginLeft;
},
setDataDecorator: function (fnDataDecorator) {
// cc.log("ListView11111------------>"+this._fnDataDecorator);
this._fnDataDecorator = fnDataDecorator;
// cc.log("ListView2222------------>"+this._fnDataDecorator);
},
getSceneCanvas: function () {
return this._compSceneCanvas;
},
getPageSize: function () {
return this._iShowCellRows;
},
setStatusInScene: function (iStatus) {
this._iStatusInScene = iStatus;
},
enableFocusInfo: function () {
//单元内该恢复的交给数据侧恢复
this.node.getChildByName('ScrollBarContainer').getChildByName('ScrollBarShadow').getChildByName('ScrollBarBlock').getComponent(FocusInfo).setEnable(true);
},
disableFocusInfo: function () {
let nodeContainer = this.node.getChildByName('DataContainerMask').getChildByName('DataContainer');
let aChildrenNodes = nodeContainer.getChildren();
for (let index in aChildrenNodes) {
let compListCell = aChildrenNodes[index].getComponent(ListCell);
if (compListCell) {
compListCell.disableFocusInfo();
}
}
this.node.getChildByName('ScrollBarContainer').getChildByName('ScrollBarShadow').getChildByName('ScrollBarBlock').getComponent(FocusInfo).setEnable(false);
},
isPFBAtStart: function (iIndexOfPFB) { //是否是第一行
let iLeftIndex = this._iPFBIndexOfFirstCellInPage;
let iRightIndex = iLeftIndex + this._iCellCountEachRow - 1;
if (iIndexOfPFB >= iLeftIndex && iIndexOfPFB <= iRightIndex) {
return true;
} else {
return false;
}
},
isPFBAtEnd: function (iIndexOfPFB) { //是否是最末行
let iLeftIndex = (this._iPFBIndexOfFirstCellInPage + (this._iShowCellRows - 1) * this._iCellCountEachRow)
% (this._iCellRowCount * this._iCellCountEachRow);
let iRightIndex = iLeftIndex + this._iCellCountEachRow - 1; //一行不会超过尾部
if (iIndexOfPFB >= iLeftIndex && iIndexOfPFB <= iRightIndex) {
return true;
} else {
return false;
}
},
getPFBIndexOfFirstCellInPage: function () {
return this._iPFBIndexOfFirstCellInPage;
},
getRecordIndexOfFirstCellInPage: function () {
return this._iRecordIndexOfFirstCellInPage;
},
getRecordCount: function () {
return this._iRecordCount;
},
getShowCellRows: function () {
return this._iShowCellRows;
},
getAlphaCellRows: function () {
return this._iAlphaCellRows;
},
getHiddenCellRows: function () {
return this._iHiddenCellRows;
},
getCellCountEachRow: function () {
return this._iCellCountEachRow;
},
setRecordCount: function (iRecordCount) {
this._iRecordCount = iRecordCount;
this.adjustScrollBarSize(this._iRecordCount);
// let nodeScrollBarContainer = this.node.getChildByName('ScrollBarContainer');
// let nodeScrollBarBlock = nodeScrollBarContainer.getChildByName('ScrollBarBlock');
},
setDataSource: function (strMethod, strURL, oParameters, iStart, iLimit, strSortField, strSortDirection) {
this._oDataSource.method = strMethod;
this._oDataSource.url = strURL;
this._oDataSource.parameters = oParameters;
this._oDataSource.start = iStart;
this._oDataSource.limit = iLimit;
this._oDataSource.sortField = strSortField;
this._oDataSource.sortDirection = strSortDirection;
},
setDataPositionRender: function (fnDataPositionRender) {
this._fnDataPositionRender = fnDataPositionRender;
},
adjustScrollBarSize: function (iRecordCount) {
let nodeScrollBarContainer = this.node.getChildByName('ScrollBarContainer');
let nodeScrollBarShadow = nodeScrollBarContainer.getChildByName('ScrollBarShadow');
let nodeScrollBarBlock = nodeScrollBarShadow.getChildByName('ScrollBarBlock');
let iShowCellCount = this._iShowCellRows * this._iCellCountEachRow;
let loc = 94;
//注释掉写死高度
if (1 == this._iSwitchDirection) { //竖着
// loc = (iShowCellCount / this._iRecordCount) * nodeScrollBarContainer.height;
// if (loc > 94) {
// nodeScrollBarBlock.height = 94;
// return;
nodeScrollBarBlock.height = loc;
}
// } else {
// loc = (iShowCellCount / this._iRecordCount) * nodeScrollBarContainer.width;
// if (loc > 94) {
// nodeScrollBarBlock.width = 94;
// return;
// }
// }
},
renderInitData: function (strResponse, fnCalback) {
try {
//此函数一般start为0
//由于光标恢复的需要,希望光标所在PFB和记录的一致,所以PFB的使用,也从start开始
var oJSONResult = JSON.parse(strResponse);
this._iRecordCount = oJSONResult.count;
this.adjustScrollBarSize(this._iRecordCount);
// let nodeScrollBarContainer = this.node.getChildByName('ScrollBarContainer');
// let nodeScrollBarBlock = nodeScrollBarContainer.getChildByName('ScrollBarBlock');
let nodeScrollBarContainer = this.node.getChildByName('ScrollBarContainer');
let nodeScrollBarShadow = nodeScrollBarContainer.getChildByName('ScrollBarShadow');
let nodeScrollBarBlock = nodeScrollBarShadow.getChildByName('ScrollBarBlock');
if (1 == this._iTitleDirection) {
nodeScrollBarBlock.y = nodeScrollBarContainer.height / 2 - nodeScrollBarBlock.height / 2;
} else {
nodeScrollBarBlock.x = -nodeScrollBarContainer.width / 2 + nodeScrollBarBlock.width / 2;
}
if (oJSONResult.businessCode == "success") {
//准备上头那行
let nodeContainer = this.node.getChildByName('DataContainerMask').getChildByName('DataContainer');
if (oJSONResult.resultSet.length > 0) {//返回有记录
let oData1 = {};
oData1.refData = oJSONResult.resultSet;
this._iRecordIndexOfFirstCellInPage = this._oDataSource.start;
//this.putScrollBarBlockInPosition(this._iRecordIndexOfFirstCellInPage);
if (this._fnDataPositionRender && typeof this._fnDataPositionRender == 'function') {
this._fnDataPositionRender(this._iRecordIndexOfFirstCellInPage + 1, oJSONResult.count);
}
this._fnDataDecorator(oData1, function (compCanvas) {
//初始化 TODO:其他的要隐藏
for (let i = 0; i < (this._iShowCellRows + this._iAlphaCellRows + this._iHiddenCellRows) * this._iCellCountEachRow; i++) {
let nodeCell = nodeContainer.getChildByName(this._strListCellName
+ ((this._oDataSource.start + i) % (this._iCellRowCount * this._iCellCountEachRow))); //这里第一次显示如果不是从头开始显示的,则要使用准确的PFB来操作
let compCell = nodeCell.getComponent(ListCell);
if (i < oJSONResult.resultSet.length) {
//准备到最下面Alpha的后面,这要注意兼容两个方向
if (1 == this._iTitleDirection) { //一个个往右铺,一行行往下铺
nodeCell.x = this._fCellStartX + (this._fCellMarginLeft + nodeCell.width + this._fCellMarginRight)
* ((this._oDataSource.start + i) % this._iCellCountEachRow); //加不加start问题不大
nodeCell.y = this._fCellStartY - (this._fCellMarginTop + nodeCell.height + this._fCellMarginBottom)
* Math.floor((this._oDataSource.start + i) / this._iCellCountEachRow);
} else { //一个个往下铺,一列列往右铺
nodeCell.y = this._fCellStartY - (this._fCellMarginTop + nodeCell.height + this._fCellMarginBottom)
* ((this._oDataSource.start + i) % this._iCellCountEachRow); //加不加start问题不大
nodeCell.x = this._fCellStartX + (this._fCellMarginLeft + nodeCell.width + this._fCellMarginRight)
* Math.floor((this._oDataSource.start + i) / this._iCellCountEachRow);
}
compCell.render(oJSONResult.resultSet[i], this._oDataSource.start + i); //使用细胞自己的渲染器
//下面的i不修改因为要根据显示的情况来设置
if (i < this._iShowCellRows * this._iCellCountEachRow) {
compCell.enableFocusInfo();//cc.log(this._iShowCellRows*this._iCellCountEachRow+"(a)"+i);
compCell.node.opacity = 255;
} else if (i < (this._iShowCellRows + this._iAlphaCellRows) * this._iCellCountEachRow) {
//即使下方数据不满一行上面也要全部失效
compCell.disableFocusInfo();//cc.log("(b)"+i);
compCell.node.opacity = 100;
} else {
compCell.disableFocusInfo();//cc.log("(c)"+i);
compCell.node.opacity = 0;
}
//------------2.0版本-------
nodeCell.active = true;
//--------------------------
} else {
compCell.disableFocusInfo();
compCell.node.opacity = 0;
}
}
//TODO: 最后一行的半透明增加,部分的 半透明处理
//飞完光标后把上下文都处理干净
this._iRecordIndexOfFirstCellInPage = this._oDataSource.start;
this._iPFBIndexOfFirstCellInPage = (this._oDataSource.start + 0) % (this._iCellRowCount * this._iCellCountEachRow);
//把ScrollBarBlock移动到合适位置
this.putScrollBarBlockInPosition(this._iRecordIndexOfFirstCellInPage);
}, this);
} else {
//--------------------------------------2.0版本-------------------------------------
// for (let i = 0; i < (this._iShowCellRows * 2 + this._iAlphaCellRows) * this._iCellCountEachRow; i++) {
// let nodeCell = nodeContainer.getChildByName(this._strListCellName + i);
// let compCell = nodeCell.getComponent(ListCell);
// compCell.disableFocusInfo();//cc.log("(c)"+i);
// compCell.node.opacity = 0;
// }
// if (this._fnDataPositionRender && typeof this._fnDataPositionRender == 'function') {
// this._fnDataPositionRender(0, 0);
// }
//----------------------------------------------------------------------------------
}
let nodeFirst = nodeContainer.getChildByName(this._strListCellName + '0');
let ftaSearchResultMoveTo = null;
if (nodeFirst) {
if (1 == this._iTitleDirection) {
ftaSearchResultMoveTo = cc.moveTo(
0.1,
0,
0 + Math.floor((this._oDataSource.start) / this._iCellCountEachRow) * (this._fCellMarginTop + nodeFirst.height + this._fCellMarginBottom)
);
} else {
ftaSearchResultMoveTo = cc.moveTo(
0.1,
0 - Math.floor((this._oDataSource.start) / this._iCellCountEachRow) * (this._fCellMarginLeft + nodeFirst.width + this._fCellMarginRight),
0
);
}
let ftaSearchResultSequence = new cc.sequence(ftaSearchResultMoveTo,
cc.callFunc(function (target, param1) {
let callback = param1[1];
callback && callback.call(param1[0]);//这么加不知道正不正
}, this, [this._compSceneCanvas, fnCalback])
);
ftaSearchResultSequence.setTag(11);
nodeContainer.stopAction(nodeContainer.getActionByTag(11));
nodeContainer.runAction(ftaSearchResultSequence);
}
cc.log("Business Success : ListView renderInitData ");
} else {
cc.log("Business Error : ListView renderInitData..." + oJSONResult.description);
}
} catch (ex) {
cc.log("Business Exception : ListView renderInitData..." + ex);
}
},
loadData: function (onSuccess, onError, oScope) {
let oAllParameters = {};
oAllParameters.view = 'json';
//自定义参数
for (let strKey in this._oDataSource.parameters) {
oAllParameters[strKey] = this._oDataSource.parameters[strKey];
}
//oAllParameters.keyword=this._oDataSource.parameters.keyword;
//常见参数
if (null == this._oDataSource.start || this._oDataSource.start < 0) {
oAllParameters.start = 0;
} else {
oAllParameters.start = this._oDataSource.start;
}
if (null == this._oDataSource.limit || this._oDataSource.limit <= 0) {
oAllParameters.limit = (this._iShowCellRows) * this._iCellCountEachRow; //默认取一页
} else {
oAllParameters.limit = this._oDataSource.limit;
}
if (null != this._oDataSource.sortField && '' != this._oDataSource.sortField) {
oAllParameters.sortField = this._oDataSource.sortField;
} else {
delete oAllParameters.sortField;
}
if (null != this._oDataSource.sortDirection && '' != this._oDataSource.sortDirection) {
oAllParameters.sortDirection = this._oDataSource.sortDirection;
} else {
delete oAllParameters.sortDirection;
}
oAllParameters.token = Common.TEST_API_TOKEN_EDU;
if (null == onSuccess) {
onSuccess = this.renderInitData;
}
if (null == onError) {
onError = function (strResponse) {
cc.log("Communication Error : Load init data in ListView..." + strResponse + "\r\n");
}
}
if (null == oScope) {
oScope = this;
}
Network.ajax(this._oDataSource.method, this._oDataSource.url,
null, oAllParameters,
onSuccess, onError,
oScope, "uuid"
);//Ajax
},
scrollARowUp: function (index) { //往上探一行,Container向下移动一行
if (this._iRecordIndexOfFirstCellInPage < this._iCellCountEachRow) {//已经没有数据可以向上滚了 啥也不干
return false; //其实这里用不上,一般在外面判断已经拦截
}
//--------------------------------------modify row problem--------------------------------
// if (this._iRecordIndexOfFirstCellInPage <= 0) {//已经没有数据可以向上滚了 啥也不干
// return false;
// }
if (index >= (this._iRecordIndexOfFirstCellInPage % (this._iCellRowCount * this._iCellCountEachRow))
&& index <= (this._iRecordIndexOfFirstCellInPage % (this._iCellRowCount * this._iCellCountEachRow)) + this._iCellCountEachRow - 1) {//如果是头排,roll
} else {
return false;
}
//------------------------------------------------------------------------------------------
this._compSceneCanvas.onListScrollStart && this._compSceneCanvas.onListScrollStart();
//查询条件不变,就滚行
this._oDataSource.start = this._iRecordIndexOfFirstCellInPage - this._iCellCountEachRow;
this._oDataSource.limit = this._iCellCountEachRow;
this.loadData(
function (strResponse) { //获取数据成功
try {
var oJSONResult = JSON.parse(strResponse);
this._iRecordCount = oJSONResult.count;
this.adjustScrollBarSize(this._iRecordCount);
if (oJSONResult.businessCode == "success" && oJSONResult.resultSet.length > 0) { //返回有记录
//准备上头那行
let nodeContainer = this.node.getChildByName('DataContainerMask').getChildByName('DataContainer');
let oData1 = {};
oData1.refData = oJSONResult.resultSet;
this._fnDataDecorator(oData1, function () {
//这么复杂是为了在翻到较后面的页面上,防止第一个PFB往上切到上面循环的最后一个PFB的情况
let iStartPFBIndex = (this._iPFBIndexOfFirstCellInPage
+ this._iCellRowCount * this._iCellCountEachRow
- this._iCellCountEachRow)
% (this._iCellRowCount * this._iCellCountEachRow);
let nodeFirst = nodeContainer.getChildByName(this._strListCellName + this._iPFBIndexOfFirstCellInPage);
//搞一行 准备位置
for (let i = 0; i < this._iCellCountEachRow; i++) {
if (i < oJSONResult.resultSet.length) { //有数据的部分
let nodeCell = nodeContainer.getChildByName(this._strListCellName + (iStartPFBIndex + i));
//准备到最下面Alpha的后面,这要注意兼容两个方向
if (1 == this._iTitleDirection) { //一个个往右铺,一行行往下铺
nodeCell.x = nodeFirst.x + (this._fCellMarginLeft + nodeCell.width + this._fCellMarginRight) * i;
nodeCell.y = nodeFirst.y + (this._fCellMarginTop + nodeCell.height + this._fCellMarginBottom);
} else { //一个个往下铺,一行行往右铺
nodeCell.x = nodeFirst.x - (this._fCellMarginLeft + nodeCell.width + this._fCellMarginRight);
nodeCell.y = nodeFirst.y - (this._fCellMarginTop + nodeCell.height + this._fCellMarginBottom) * i;
}
let compCell = nodeCell.getComponent(ListCell);
compCell.render(oJSONResult.resultSet[i], this._iRecordIndexOfFirstCellInPage - this._iCellCountEachRow + i); //使用细胞自己的渲染器
compCell.enableFocusInfo();
compCell.node.opacity = 255;
//-----------2.0版本--------
nodeCell.active = true;
//--------------------------
}
//最后一行显示的变成半透明,焦点无效,原来半透明往下 不管了,以后会重新设置
if (this._iRecordIndexOfFirstCellInPage + (this._iShowCellRows - 1) * this._iCellCountEachRow + i < this._iRecordCount) {
let iIndexOfCellNeedAlpha = (this._iPFBIndexOfFirstCellInPage
+ (this._iShowCellRows - 1) * this._iCellCountEachRow + i)
% (this._iCellRowCount * this._iCellCountEachRow);
let compCellNeedAlpha = nodeContainer.getChildByName(this._strListCellName + iIndexOfCellNeedAlpha).getComponent(ListCell);
compCellNeedAlpha.disableFocusInfo();
compCellNeedAlpha.node.opacity = 100;
}
}
//开始指挥外面飞焦点
let fScrollStep = 0;
let iDirection = 0;
//向前翻一行
if (1 == this._iTitleDirection) { //一个个往右铺 一行行往下铺
fScrollStep = this._fCellMarginTop + nodeFirst.height + this._fCellMarginBottom;
iDirection = Common.MOVE_DIRECTION_UP;
} else { //一个个往下铺 一行行往右铺
fScrollStep = this._fCellMarginLeft + nodeFirst.width + this._fCellMarginRight;
iDirection = Common.MOVE_DIRECTION_LEFT;
}
let cFocus = this._compSceneCanvas.getFocus();
let fiFocusTarget = cFocus.findTarget(null, null, this._iStatusInScene, iDirection);
let oScrollParameter = this.node.getChildByName('DataContainerMask')
.getChildByName('DataContainer')
.getComponent(TVScrollParameter);
if (1 == this._iTitleDirection) { //一个个往右铺 一行行往下铺
oScrollParameter.setTargetPosition(
(Math.floor(this._iRecordIndexOfFirstCellInPage / this._iCellCountEachRow) - 1) * fScrollStep);
oScrollParameter.setDirection(iDirection);
} else { //一个个往下铺 一行行往右铺
oScrollParameter.setTargetPosition(
-(Math.floor(this._iRecordIndexOfFirstCellInPage / this._iCellCountEachRow) - 1) * fScrollStep);
}
oScrollParameter.setStep(fScrollStep);
oScrollParameter.setHasRelation(true);
oScrollParameter.callback = function () {
arguments[1].hideCellOutOfDisplayArea();
arguments[1]._compSceneCanvas.onListScrollEnd && arguments[1]._compSceneCanvas.onListScrollEnd();
}
oScrollParameter.scope = this;
cFocus.flyFocus(null, fiFocusTarget, iDirection, null, oScrollParameter);
//飞完光标后把上下文都处理干净
this._iRecordIndexOfFirstCellInPage -= this._iCellCountEachRow;
this._iPFBIndexOfFirstCellInPage = iStartPFBIndex;
if (this._fnDataPositionRender && typeof this._fnDataPositionRender == 'function') {
this._fnDataPositionRender(this._iRecordIndexOfFirstCellInPage + 1, oJSONResult.count);
}
this.putScrollBarBlockInPosition();
}, this);
cc.log("Business Success : DataList scrollARowUp");
} else {
if (this._fnDataPositionRender && typeof this._fnDataPositionRender == 'function') {
this._fnDataPositionRender(0, 0);
}
cc.log("Business Error : DataList scrollARowUp..." + oJSONResult.description);
}
} catch (ex) {
cc.log("Business Exception : DataList scrollARowUp..." + ex);
}
},
function (strResponse) {
cc.log("Communication Error : DataList scrollARowUp..." + strResponse);
},
this
);
return true;
},
scrollARowDown: function (onDataLoad, index) {
//常见参数
//算上显示的和灰色的最下一行
let iRecordIndexOfBottomFirst = this._iRecordIndexOfFirstCellInPage + (this._iShowCellRows + this._iAlphaCellRows) * this._iCellCountEachRow;
if (iRecordIndexOfBottomFirst - this._iAlphaCellRows * this._iCellCountEachRow > this._iRecordCount - 1) {//已经没有数据可以向下滚了 啥也不干
return false;
}
//---------------------------------about row problem-----------------------------------------------
// if (this._iRecordIndexOfFirstCellInPage + this._iShowCellRows * this._iCellCountEachRow - 1 >= this._iRecordCount - 1) {//已经没有数据可以向下滚了 啥也不干
// return false; //show部分的最后一条记录小于记录总数,下面Alpha部分都是没内容的了
// }
if ((this._iRecordIndexOfFirstCellInPage + this._iShowCellRows * this._iCellCountEachRow - 1) <= (this._iCellRowCount * this._iCellCountEachRow)) {
if (index >= this._iRecordIndexOfFirstCellInPage + this._iShowCellRows * this._iCellCountEachRow - this._iCellCountEachRow
&& index <= this._iRecordIndexOfFirstCellInPage + this._iShowCellRows * this._iCellCountEachRow - 1) {//如果是末排,roll
} else {
return false;
}
} else { //这时的数目已经超过了ListView预制的条目
//还不是末排,不滚动
if (index >= (this._iRecordIndexOfFirstCellInPage % (this._iCellRowCount * this._iCellCountEachRow))
&& index < ((this._iRecordIndexOfFirstCellInPage % (this._iCellRowCount * this._iCellCountEachRow)) + (this._iShowCellRows * this._iCellCountEachRow - this._iCellCountEachRow))) {
return false;
}
}
//------------------------------------------------------------------------------------------------------
this._compSceneCanvas.onListScrollStart && this._compSceneCanvas.onListScrollStart();
if (iRecordIndexOfBottomFirst > this._iRecordCount - 1) { //只是滚行 但是不查询
let iStartPFBIndex = (this._iPFBIndexOfFirstCellInPage + this._iShowCellRows * this._iCellCountEachRow)
% (this._iCellRowCount * this._iCellCountEachRow);
let nodeContainer = this.node.getChildByName('DataContainerMask').getChildByName('DataContainer');
let nodeFirst = nodeContainer.getChildByName(this._strListCellName + this._iPFBIndexOfFirstCellInPage);
//只要移动一行
for (let i = 0; i < this._iCellCountEachRow; i++) {
if (iRecordIndexOfBottomFirst - this._iAlphaCellRows * this._iCellCountEachRow + i <= this._iRecordCount - 1) { //考虑不满一行的情况
let nodeCell = nodeContainer.getChildByName(this._strListCellName + (iStartPFBIndex + i));//一行就不求模了
let compCell = nodeCell.getComponent(ListCell);
compCell.enableFocusInfo();//这一行并不设置焦点可达,只是填充成Alpha
compCell.node.opacity = 255;
}
//即使下方数据不满一行上面也要全部失效,由于被Mask,是否显示倒不是很关键
let iIndexOfCellNeedHide = this._iPFBIndexOfFirstCellInPage + i;
let compCellNeedHide = nodeContainer.getChildByName(this._strListCellName + iIndexOfCellNeedHide)
.getComponent(ListCell);
compCellNeedHide.disableFocusInfo();
compCellNeedHide.opacity = 0;
}
//开始指挥外面飞焦点
let fScrollStep = 0;
let iDirection = 0;
//向前翻一行
if (1 == this._iTitleDirection) { //一个个往右铺,一行行往下铺
fScrollStep = this._fCellMarginTop + nodeFirst.height + this._fCellMarginBottom;
iDirection = Common.MOVE_DIRECTION_DOWN;
} else { //一个个往下铺,一行行往右铺
fScrollStep = this._fCellMarginLeft + nodeFirst.width + this._fCellMarginRight;
iDirection = Common.MOVE_DIRECTION_RIGHT;
}
let cFocus = this._compSceneCanvas.getFocus();
let fiFocusTarget = cFocus.findTarget(null, null, this._iStatusInScene, iDirection);
let oScrollParameter = this.node.getChildByName('DataContainerMask')
.getChildByName('DataContainer')
.getComponent(TVScrollParameter);
if (1 == this._iTitleDirection) { //一个个往右铺 一行行往下铺
oScrollParameter.setTargetPosition(
(Math.floor(this._iRecordIndexOfFirstCellInPage / this._iCellCountEachRow) + 1) * fScrollStep);
oScrollParameter.setDirection(iDirection);
} else { //一个个往下铺 一行行往右铺
oScrollParameter.setTargetPosition(
-(Math.floor(this._iRecordIndexOfFirstCellInPage / this._iCellCountEachRow) + 1) * fScrollStep);
}
oScrollParameter.setStep(fScrollStep);
oScrollParameter.setHasRelation(true);
oScrollParameter.callback = function () {
arguments[1].hideCellOutOfDisplayArea();
arguments[1]._compSceneCanvas.onListScrollEnd && arguments[1]._compSceneCanvas.onListScrollEnd();
}
oScrollParameter.scope = this;
cFocus.flyFocus(null, fiFocusTarget, iDirection, null, oScrollParameter);
//飞完光标后把上下文都处理干净
this._iRecordIndexOfFirstCellInPage += this._iCellCountEachRow;
this._iPFBIndexOfFirstCellInPage = (this._iPFBIndexOfFirstCellInPage + this._iCellCountEachRow)
% (this._iCellRowCount * this._iCellCountEachRow);
if (this._fnDataPositionRender && typeof this._fnDataPositionRender == 'function') {
this._fnDataPositionRender(this._iRecordIndexOfFirstCellInPage + 1, this._iRecordCount);
}
this.putScrollBarBlockInPosition();
return true;
}
//查询条件不变,就滚行
this._oDataSource.start = iRecordIndexOfBottomFirst;
this._oDataSource.limit = this._iCellCountEachRow;
this.loadData(
function (strResponse) { //获取数据成功
try {
var oJSONResult = JSON.parse(strResponse);
this._iRecordCount = oJSONResult.count;
this.adjustScrollBarSize(this._iRecordCount);
if (oJSONResult.businessCode == "success" && oJSONResult.resultSet.length > 0) { //返回有记录
//准备上头那行
let nodeContainer = this.node.getChildByName('DataContainerMask').getChildByName('DataContainer');
let oData1 = {};
oData1.refData = oJSONResult.resultSet;
this._fnDataDecorator(oData1, function () {
let iStartPFBIndex = (this._iPFBIndexOfFirstCellInPage + (this._iShowCellRows + this._iAlphaCellRows) * this._iCellCountEachRow)
% (this._iCellRowCount * this._iCellCountEachRow);
let nodeFirst = nodeContainer.getChildByName(this._strListCellName + this._iPFBIndexOfFirstCellInPage);
//准备需要显示的数据
for (let i = 0; i < this._iCellCountEachRow; i++) {
if (i < oJSONResult.resultSet.length) { //有数据的部分
let nodeCell = nodeContainer.getChildByName(this._strListCellName + (iStartPFBIndex + i));//一行,所以不求模了
//let nodeFirst=nodeContainer.getChildByName('ListCell'+this._iPFBIndexOfFirstCellInPage);
//准备到最下面Alpha的后面,这要注意兼容两个方向
if (1 == this._iTitleDirection) { //一个个往右铺,一行行往下铺
nodeCell.x = nodeFirst.x + (this._fCellMarginLeft + nodeCell.width + this._fCellMarginRight) * i;
nodeCell.y = nodeFirst.y - (this._iShowCellRows + this._iAlphaCellRows) * (this._fCellMarginTop + nodeCell.height + this._fCellMarginBottom);
//fScrollStep=this._fCellMarginTop+nodeCell.height+this._fCellMarginBottom;
} else { //一个个往下铺,一行行往右铺
nodeCell.x = nodeFirst.x + (this._iShowCellRows + this._iAlphaCellRows) * (this._fCellMarginLeft + nodeCell.width + this._fCellMarginRight);
nodeCell.y = nodeFirst.y - (this._fCellMarginTop + nodeCell.height + this._fCellMarginBottom) * i;
//fScrollStep=this._fCellMarginLeft+nodeCell.width+this._fCellMarginRight;
}
let compCell = nodeCell.getComponent(ListCell);
compCell.render(
oJSONResult.resultSet[i],
this._iRecordIndexOfFirstCellInPage + (this._iShowCellRows + this._iAlphaCellRows) * this._iCellCountEachRow + i); //使用细胞自己的渲染器
compCell.disableFocusInfo();//这一行并不设置焦点可达,只是填充成Alpha
compCell.node.opacity = 100;
//------------2.0版本--------
nodeCell.active = true;
//---------------------------
}
//第一行Alpha要变成Show,焦点变成有效,需要注意Alpha不止一行的情况 其实上面代码在底部添加了一行Alpha,
//下面代码Alpha变一行Show,中间不动都是Alpha
//if (this._iRecordIndexOfFirstCellInPage+(this._iShowCellRows-1)*this._iCellCountEachRow + i < this._iRecordCount){
let iIndexOfCellNeedShow = (this._iPFBIndexOfFirstCellInPage
+ this._iShowCellRows * this._iCellCountEachRow + i)
% (this._iCellRowCount * this._iCellCountEachRow);
let compCellNeedShow = nodeContainer.getChildByName(this._strListCellName + iIndexOfCellNeedShow).getComponent(ListCell);
compCellNeedShow.enableFocusInfo();
compCellNeedShow.node.opacity = 255;
//}
}
//开始指挥外面飞焦点
let fScrollStep = 0;
let iDirection = 0
//向前翻一行
if (1 == this._iTitleDirection) { //一个个往右铺,一行行往下铺
fScrollStep = this._fCellMarginTop + nodeFirst.height + this._fCellMarginBottom;
iDirection = Common.MOVE_DIRECTION_DOWN;
} else { //一个个往下铺,一行行往右铺
fScrollStep = this._fCellMarginLeft + nodeFirst.width + this._fCellMarginRight;
iDirection = Common.MOVE_DIRECTION_RIGHT;
}
let cFocus = this._compSceneCanvas.getFocus();
let fiFocusTarget = cFocus.findTarget(null, null, this._iStatusInScene, iDirection);
let oScrollParameter = this.node.getChildByName('DataContainerMask')
.getChildByName('DataContainer')
.getComponent(TVScrollParameter);
if (1 == this._iTitleDirection) { //一个个往右铺 一行行往下铺
oScrollParameter.setTargetPosition(
(Math.floor(this._iRecordIndexOfFirstCellInPage / this._iCellCountEachRow) + 1) * fScrollStep);
oScrollParameter.setDirection(iDirection);
} else { //一个个往下铺 一行行往右铺
oScrollParameter.setTargetPosition(
-(Math.floor(this._iRecordIndexOfFirstCellInPage / this._iCellCountEachRow) + 1) * fScrollStep);
}
oScrollParameter.setStep(fScrollStep);
oScrollParameter.setHasRelation(true);
oScrollParameter.callback = function () {
arguments[1].hideCellOutOfDisplayArea();
arguments[1]._compSceneCanvas.onListScrollEnd && arguments[1]._compSceneCanvas.onListScrollEnd();
}
oScrollParameter.scope = this;
cFocus.flyFocus(null, fiFocusTarget, iDirection, null, oScrollParameter);
//需要隐藏的东西
for (let i = 0; i < this._iCellCountEachRow; i++) {
//即使下方数据不满一行上面也要全部失效,由于被Mask,是否显示倒不是很关键
let iIndexOfCellNeedHide = this._iPFBIndexOfFirstCellInPage + i;
let compCellNeedHide = nodeContainer.getChildByName(this._strListCellName + iIndexOfCellNeedHide)
.getComponent(ListCell);
compCellNeedHide.disableFocusInfo();
compCellNeedHide.opacity = 0;
}
//飞完光标后把上下文都处理干净
this._iRecordIndexOfFirstCellInPage += this._iCellCountEachRow;
this._iPFBIndexOfFirstCellInPage = (this._iPFBIndexOfFirstCellInPage + this._iCellCountEachRow)
% (this._iCellRowCount * this._iCellCountEachRow);
if (this._fnDataPositionRender && typeof this._fnDataPositionRender == 'function') {
this._fnDataPositionRender(this._iRecordIndexOfFirstCellInPage + 1, oJSONResult.count);
}
this.putScrollBarBlockInPosition();
}, this);
cc.log("Business Success : SongList scrollARowDown");
} else {
if (this._fnDataPositionRender && typeof this._fnDataPositionRender == 'function') {
this._fnDataPositionRender(0, 0);
}
cc.log("Business Error : SongList scrollARowDown..." + oJSONResult.description);
}
} catch (ex) {
cc.log("Business Exception : SongList scrollARowDown..." + ex);
}
},
function (strResponse) {
cc.log("Communication Error : DataList scrollARowDown..." + strResponse);
},
this
);
return true;
},
scrollAPageUp: function () { //网上探一页,Container向下移动一页
//let iGetRecords=0;
if (this._iRecordIndexOfFirstCellInPage <= 0) {//已经没有数据可以向上滚了 啥也不干
return false;
} else if (this._iRecordIndexOfFirstCellInPage < this._iShowCellRows * this._iCellCountEachRow) {
//上面有不满一页的数据
//就只拿出顶端那几行,否则即使拿到,也会覆写掉下面的
//0~this._iRecordIndexOfFirstCellInPage-1
this._oDataSource.start = 0;
this._oDataSource.limit = this._iRecordIndexOfFirstCellInPage;
//iGetRecords=this._iRecordIndexOfFirstCellInPage;
} else {
//可以拿出完整一页
this._oDataSource.start = this._iRecordIndexOfFirstCellInPage - (this._iShowCellRows * this._iCellCountEachRow);
this._oDataSource.limit = this._iShowCellRows * this._iCellCountEachRow;
//iGetRecords=this._iShowCellRows*this._iCellCountEachRow;
}
this._compSceneCanvas.onListScrollStart && this._compSceneCanvas.onListScrollStart();
this.loadData(
function (strResponse) { //获取数据成功
try {
var oJSONResult = JSON.parse(strResponse);
this._iRecordCount = oJSONResult.count;
this.adjustScrollBarSize(this._iRecordCount);
if (oJSONResult.businessCode == "success" && oJSONResult.resultSet.length > 0) { //返回有记录
let iGetRecords = oJSONResult.resultSet.length; //一般总能取满
let iGetRows = Math.ceil(iGetRecords / this._iCellCountEachRow); //根据结果来调整,一般总是预期的行数 满页或者不满页
let iScrollRows = iGetRows; //向上总是得到几行滚几行
//准备上头那行
let nodeContainer = this.node.getChildByName('DataContainerMask').getChildByName('DataContainer');
let oData1 = {};
oData1.refData = oJSONResult.resultSet;
this._fnDataDecorator(oData1, function () {
//这么复杂是为了在翻到较后面的页面上,防止第一个PFB往上切到上面循环的最后一个PFB的情况
let iStartPFBIndex = (this._iPFBIndexOfFirstCellInPage
+ this._iCellRowCount * this._iCellCountEachRow
- iGetRecords) //只有在好多内容数量突然减少到不满一页 才会发生Bug
% (this._iCellRowCount * this._iCellCountEachRow);
let nodeFirst = nodeContainer.getChildByName(this._strListCellName + this._iPFBIndexOfFirstCellInPage);
//准备渲染
for (let i = 0; i < iGetRecords; i++) { //向上的翻页一般都数量一致
if (i < oJSONResult.resultSet.length) { //有数据的部分
let nodeCell = nodeContainer.getChildByName(this._strListCellName
+ ((iStartPFBIndex + i) % (this._iCellRowCount * this._iCellCountEachRow)));
//let nodeFirst=nodeContainer.getChildByName('ListCell'+this._iPFBIndexOfFirstCellInPage);
//准备到最下面Alpha的后面,这要注意兼容两个方向
if (1 == this._iTitleDirection) { //一个个往右铺,一行行往下铺
nodeCell.x = nodeFirst.x + (this._fCellMarginLeft + nodeCell.width + this._fCellMarginRight)
* (i % this._iCellCountEachRow);
nodeCell.y = nodeFirst.y + (this._fCellMarginTop + nodeCell.height + this._fCellMarginBottom)
* (Math.ceil((iGetRecords - i) / this._iCellCountEachRow));
} else { //一个个往下铺,一行行往右铺
nodeCell.x = nodeFirst.x - (this._fCellMarginLeft + nodeCell.width + this._fCellMarginRight)
* (Math.ceil((iGetRecords - i) / this._iCellCountEachRow));
nodeCell.y = nodeFirst.y - (this._fCellMarginTop + nodeCell.height + this._fCellMarginBottom)
* (i % this._iCellCountEachRow);
}
let compCell = nodeCell.getComponent(ListCell);
compCell.render(oJSONResult.resultSet[i], this._iRecordIndexOfFirstCellInPage - iGetRecords + i); //使用细胞自己的渲染器
compCell.enableFocusInfo();
compCell.node.opacity = 255;
//---------------2.0版本---------
nodeCell.active = true;
//-------------------------------
}
}
//开始指挥外面飞焦点
let fScrollStep = 0;
let iDirection = 0
//向前翻一行
if (1 == this._iTitleDirection) { //一个个往右铺 一行行往下铺
fScrollStep = (this._fCellMarginTop + nodeFirst.height + this._fCellMarginBottom);//其实这里一般都是整数
iDirection = Common.MOVE_DIRECTION_UP;
} else { //一个个往下铺 一行行往右铺
fScrollStep = (this._fCellMarginLeft + nodeFirst.width + this._fCellMarginRight);
iDirection = Common.MOVE_DIRECTION_LEFT;
}
let ftaSearchResultMoveTo = null;
if (Common.MOVE_DIRECTION_UP == iDirection) {
//ftaSearchResultMoveTo=cc.moveTo(0.4,nodeContainer.x,nodeContainer.y-fScrollStep*iScrollRows);
ftaSearchResultMoveTo = cc.moveTo(
0.4,
nodeContainer.x,
(Math.floor(this._iRecordIndexOfFirstCellInPage / this._iCellCountEachRow) - iScrollRows) * fScrollStep
);
} else if (Common.MOVE_DIRECTION_LEFT == iDirection) {
//ftaSearchResultMoveTo=cc.moveTo(0.4,nodeContainer.x+fScrollStep*iScrollRows,nodeContainer.y);
ftaSearchResultMoveTo = cc.moveTo(
0.4,
-(Math.floor(this._iRecordIndexOfFirstCellInPage / this._iCellCountEachRow) - iScrollRows) * fScrollStep,
nodeContainer.y
);
}
let ftaSearchResultSequence = new cc.sequence(ftaSearchResultMoveTo,
cc.callFunc(function (target, param1) {
for (let i = 0; i < iGetRecords; i++) { //向上的翻页一般都数量一致
// 半透明的处理 注意Alpha不止一行的情况
// 由于是向上翻,所以一般是整行,不考虑不满一行的状况
let iIndexOfCellNeedChange = (this._iPFBIndexOfFirstCellInPage
+ (this._iCellRowCount * this._iCellCountEachRow) //加一个是因为怕特殊情况变负的
- iGetRecords
+ this._iShowCellRows * this._iCellCountEachRow
+ i
)
% (this._iCellRowCount * this._iCellCountEachRow);
//let iAlphaRecordEnd=iAlphaRecordStart+this._iAlphaCellRows*this._iCellCountEachRow-1;
//处理整整一页的数据 一部分变成Alpha,新老Alpha之间的部分不显示,老Alpha保留不动,以后会被更新
if (i < this._iAlphaCellRows * this._iCellCountEachRow) {//对应关系修改Cell成Alpha
let compCellNeedAlpha = nodeContainer.getChildByName(this._strListCellName + iIndexOfCellNeedChange).getComponent(ListCell);
compCellNeedAlpha.disableFocusInfo();
compCellNeedAlpha.node.opacity = 100;
} else { //这里有点问题啊如果Alpha区域足够大。。。。超过了底部循环改到头部去,很悲催,Alpha只有一行暂时没问题
let compCellNeedHide = nodeContainer.getChildByName(this._strListCellName + iIndexOfCellNeedChange).getComponent(ListCell);
compCellNeedHide.disableFocusInfo();
compCellNeedHide.node.opacity = 0;
}
}
//飞完光标后把上下文都处理干净
this._iRecordIndexOfFirstCellInPage -= iGetRecords;
this._iPFBIndexOfFirstCellInPage = iStartPFBIndex;
if (this._fnDataPositionRender && typeof this._fnDataPositionRender == 'function') {
this._fnDataPositionRender(this._iRecordIndexOfFirstCellInPage + 1, oJSONResult.count);
}
param1[0].onListScrollEnd && param1[0].onListScrollEnd();
}, this, [this._compSceneCanvas])
);
let cFocus = this._compSceneCanvas.getFocus();
this.putScrollBarBlockInPosition(this._iRecordIndexOfFirstCellInPage - iGetRecords);
ftaSearchResultSequence.setTag(11);
nodeContainer.stopAction(nodeContainer.getActionByTag(11));
nodeContainer.runAction(ftaSearchResultSequence);
}, this);
cc.log("Business Success : SongList scrollAPageUp");
} else {
if (this._fnDataPositionRender && typeof this._fnDataPositionRender == 'function') {
this._fnDataPositionRender(0, 0);
}
cc.log("Business Error : DataList scrollAPageUp..." + oJSONResult.description);
}
} catch (ex) {
cc.log("Business Exception : DataList scrollAPageUp..." + ex);
}
},
function (strResponse) {
cc.log("Communication Error : DataList scrollAPageUp..." + strResponse);
},
this
);
return true;
},
scrollAPageDown: function () { //向下探一页 Container向上探一页
//let iGetRecords=0;
//算上显示的和灰色的 在这些下面的一行第一个PFB,如果查询到数据也是start
let iRecordIndexOfBottomFirst = this._iRecordIndexOfFirstCellInPage + (this._iShowCellRows + this._iAlphaCellRows) * this._iCellCountEachRow;
if (this._iRecordIndexOfFirstCellInPage + this._iShowCellRows * this._iCellCountEachRow - 1 >= this._iRecordCount - 1) {//已经没有数据可以向下滚了 啥也不干
return false; //show部分的最后一条记录小于记录总数,下面Alpha部分都是没内容的了
}
this._compSceneCanvas.onListScrollStart && this._compSceneCanvas.onListScrollStart();
if (this._iRecordIndexOfFirstCellInPage + (this._iShowCellRows + this._iAlphaCellRows) * this._iCellCountEachRow - 1 >= this._iRecordCount - 1) {
//不用请求,只需要吧最后Alpha的部分移动上来即可 到底有几行Alpha需要计算,一般远小于Show行数
let iScrollRows = Math.ceil(
(this._iRecordCount - 1 - (this._iRecordIndexOfFirstCellInPage + this._iShowCellRows * this._iCellCountEachRow) + 1)
/ this._iCellCountEachRow
);
let iStartPFBIndex = (this._iPFBIndexOfFirstCellInPage + this._iShowCellRows * this._iCellCountEachRow)
% (this._iCellRowCount * this._iCellCountEachRow);
let nodeContainer = this.node.getChildByName('DataContainerMask').getChildByName('DataContainer');
let nodeFirst = nodeContainer.getChildByName(this._strListCellName + this._iPFBIndexOfFirstCellInPage);
let aCompCellNeedHide = [];
for (let i = 0; i < iScrollRows * this._iCellCountEachRow; i++) {
let nodeCell = nodeContainer.getChildByName(this._strListCellName + (iStartPFBIndex + i)
% (this._iCellRowCount * this._iCellCountEachRow));
let compCell = nodeCell.getComponent(ListCell);
if (iRecordIndexOfBottomFirst - this._iAlphaCellRows * this._iCellCountEachRow + i <= this._iRecordCount - 1) { //考虑不满一行的情况
compCell.enableFocusInfo();
compCell.node.opacity = 255;
} else {
compCell.disableFocusInfo();
compCell.node.opacity = 0;
}
//即使下方数据不满一行上面也要全部失效,由于被Mask,是否显示倒不是很关键
let iIndexOfCellNeedHide = (this._iPFBIndexOfFirstCellInPage + i) % (this._iCellRowCount * this._iCellCountEachRow);
let compCellNeedHide = nodeContainer.getChildByName(this._strListCellName + iIndexOfCellNeedHide)
.getComponent(ListCell);
aCompCellNeedHide.push(compCellNeedHide);
//TODO:下面显示出来的需要Hide吗
}
//开始指挥外面飞焦点
let fScrollStep = 0;
let iDirection = 0
//向前翻一行
if (1 == this._iTitleDirection) { //一个个往右铺,一行行往下铺
fScrollStep = this._fCellMarginTop + nodeFirst.height + this._fCellMarginBottom;
iDirection = Common.MOVE_DIRECTION_DOWN;
} else { //一个个往下铺,一行行往右铺
fScrollStep = this._fCellMarginLeft + nodeFirst.width + this._fCellMarginRight;
iDirection = Common.MOVE_DIRECTION_RIGHT;
}
let cFocus = this._compSceneCanvas.getFocus();
let ftaSearchResultMoveTo = null;
if (Common.MOVE_DIRECTION_DOWN == iDirection) {
//ftaSearchResultMoveTo=cc.moveTo(0.4,nodeContainer.x,nodeContainer.y+fScrollStep*iScrollRows);
ftaSearchResultMoveTo = cc.moveTo(
0.4,
nodeContainer.x,
(Math.floor(this._iRecordIndexOfFirstCellInPage / this._iCellCountEachRow) + iScrollRows) * fScrollStep
);
} else if (Common.MOVE_DIRECTION_RIGHT == iDirection) {
//ftaSearchResultMoveTo=cc.moveTo(0.4,nodeContainer.x-fScrollStep*iScrollRows,nodeContainer.y);
ftaSearchResultMoveTo = cc.moveTo(
0.4,
-(Math.floor(this._iRecordIndexOfFirstCellInPage / this._iCellCountEachRow) + iScrollRows) * fScrollStep,
nodeContainer.y
);
}
let ftaSearchResultSequence = new cc.sequence(ftaSearchResultMoveTo,
cc.callFunc(function (target, param1) {
param1[0].onListScrollEnd && param1[0].onListScrollEnd();
let aCompCellNeedHide = param1[1];
for (let i = 0; i < aCompCellNeedHide.length; i++) {
aCompCellNeedHide[i].disableFocusInfo();
aCompCellNeedHide[i].node.opacity = 0;
}
}, this, [this._compSceneCanvas, aCompCellNeedHide])
)
ftaSearchResultSequence.setTag(11);
nodeContainer.stopAction(nodeContainer.getActionByTag(11));
nodeContainer.runAction(ftaSearchResultSequence);
//飞完光标后把上下文都处理干净
this._iRecordIndexOfFirstCellInPage += iScrollRows * this._iCellCountEachRow;
cc.log("this._iRecordIndexOfFirstCellInPage:" + this._iRecordIndexOfFirstCellInPage);
this._iPFBIndexOfFirstCellInPage = (this._iPFBIndexOfFirstCellInPage + iScrollRows * this._iCellCountEachRow)
% (this._iCellRowCount * this._iCellCountEachRow);
if (this._fnDataPositionRender && typeof this._fnDataPositionRender == 'function') {
this._fnDataPositionRender(this._iRecordIndexOfFirstCellInPage + 1, this._iRecordCount);
}
this.putScrollBarBlockInPosition();
return true;
} else {//这里可能获得很多数据,也可能获得比预期的少的数据(在两次翻页的之间正好插入或者删除一些数据会发生)
this._oDataSource.start = iRecordIndexOfBottomFirst;
this._oDataSource.limit = this._iShowCellRows * this._iCellCountEachRow; //获取一页数据,后面再根据所获的数据数量来决定处理方式
}
this.loadData(
function (strResponse) { //获取数据成功
try {
var oJSONResult = JSON.parse(strResponse);
this._iRecordCount = oJSONResult.count;
this.adjustScrollBarSize(this._iRecordCount);
if (oJSONResult.businessCode == "success" && oJSONResult.resultSet.length > 0) { //返回有记录
let iGetRecords = oJSONResult.resultSet.length;
let iGetRows = Math.ceil(iGetRecords / this._iCellCountEachRow); //根据结果来调整
let iScrollRows = 0;
if (iGetRows + this._iAlphaCellRows > this._iShowCellRows) { //看准备的数据是否取得满一页
iScrollRows = this._iShowCellRows; //向上翻一页
} else {
iScrollRows = iGetRows + this._iAlphaCellRows; //向上翻完所有的的内容
}
//准备上头那行
let nodeContainer = this.node.getChildByName('DataContainerMask').getChildByName('DataContainer');
let oData1 = {};
oData1.refData = oJSONResult.resultSet;
this._fnDataDecorator(oData1, function () {
let iStartPFBIndex = (this._iPFBIndexOfFirstCellInPage + (this._iShowCellRows + this._iAlphaCellRows) * this._iCellCountEachRow)
% (this._iCellRowCount * this._iCellCountEachRow);
let nodeFirst = nodeContainer.getChildByName(this._strListCellName + this._iPFBIndexOfFirstCellInPage);
//准备位置和渲染
for (let i = 0; i < iScrollRows * this._iCellCountEachRow; i++) { //这里不一定满的,根据查询结果可能不满一页的行数
if (i < oJSONResult.resultSet.length) { //有数据的部分
let nodeCell = nodeContainer.getChildByName(this._strListCellName
+ ((iStartPFBIndex + i) % (this._iCellRowCount * this._iCellCountEachRow)));
let compCell = nodeCell.getComponent(ListCell);
//let nodeFirst=nodeContainer.getChildByName('ListCell'+this._iPFBIndexOfFirstCellInPage);
//准备到最下面Alpha的后面,这要注意兼容两个方向
if (1 == this._iTitleDirection) { //一个个往右铺,一行行往下铺
nodeCell.x = nodeFirst.x + (this._fCellMarginLeft + nodeCell.width + this._fCellMarginRight)
* (i % this._iCellCountEachRow);
nodeCell.y = nodeFirst.y - (this._iShowCellRows + this._iAlphaCellRows + Math.floor(i / this._iCellCountEachRow))
* (this._fCellMarginTop + nodeCell.height + this._fCellMarginBottom);
//fScrollStep=this._fCellMarginTop+nodeCell.height+this._fCellMarginBottom;
} else { //一个个往下铺,一行行往右铺
nodeCell.x = nodeFirst.x + (this._iShowCellRows + this._iAlphaCellRows + Math.floor(i / this._iCellCountEachRow))
* (this._fCellMarginLeft + nodeCell.width + this._fCellMarginRight);
nodeCell.y = nodeFirst.y - (this._fCellMarginTop + nodeCell.height + this._fCellMarginBottom)
* (i % this._iCellCountEachRow);
//fScrollStep=this._fCellMarginLeft+nodeCell.width+this._fCellMarginRight;
}
compCell.render(
oJSONResult.resultSet[i],
this._iRecordIndexOfFirstCellInPage + (this._iShowCellRows + this._iAlphaCellRows) * this._iCellCountEachRow + i
); //使用细胞自己的渲染器
compCell.disableFocusInfo(); //屁股后面加出来的先变成Alpha的,下面部分的代码会重新设置Show
compCell.node.opacity = 100;
//------------2.0版本----------
nodeCell.active = true;
//-----------------------------
}
//原来Alpha那几行加上新添加的小于Show行的部分,需要Show ,这里股行数不满,是不会进入这个循环的
let iIndexOfCellNeedShow = (this._iPFBIndexOfFirstCellInPage
+ this._iShowCellRows * this._iCellCountEachRow + i) //加一个是因为怕特殊情况变负的
% (this._iCellRowCount * this._iCellCountEachRow);
let compCellNeedShow = nodeContainer.getChildByName(this._strListCellName + iIndexOfCellNeedShow).getComponent(ListCell);
if (i < this._iAlphaCellRows * this._iCellCountEachRow + iGetRecords) {
compCellNeedShow.enableFocusInfo();
compCellNeedShow.node.opacity = 255;
} else {
compCellNeedShow.enableFocusInfo();
compCellNeedShow.node.opacity = 0;
}
}
//开始指挥外面飞焦点
let fScrollStep = 0;
let iDirection = 0;
//向前翻一行
if (1 == this._iTitleDirection) { //一个个往右铺,一行行往下铺
fScrollStep = (this._fCellMarginTop + nodeFirst.height + this._fCellMarginBottom);
iDirection = Common.MOVE_DIRECTION_DOWN;
} else { //一个个往下铺,一行行往右铺
fScrollStep = (this._fCellMarginLeft + nodeFirst.width + this._fCellMarginRight);
iDirection = Common.MOVE_DIRECTION_RIGHT;
}
let ftaSearchResultMoveTo = null;
if (Common.MOVE_DIRECTION_DOWN == iDirection) {
//ftaSearchResultMoveTo=cc.moveTo(0.4,nodeContainer.x,nodeContainer.y+fScrollStep*iScrollRows);
ftaSearchResultMoveTo = cc.moveTo(
0.4,
nodeContainer.x,
(Math.floor(this._iRecordIndexOfFirstCellInPage / this._iCellCountEachRow) + iScrollRows) * fScrollStep
);
} else if (Common.MOVE_DIRECTION_RIGHT == iDirection) {
//ftaSearchResultMoveTo=cc.moveTo(0.4,nodeContainer.x-fScrollStep*iScrollRows,nodeContainer.y);
ftaSearchResultMoveTo = cc.moveTo(
0.4,
-(Math.floor(this._iRecordIndexOfFirstCellInPage / this._iCellCountEachRow) + iScrollRows) * fScrollStep,
nodeContainer.y
);
}
let ftaSearchResultSequence = new cc.sequence(ftaSearchResultMoveTo,
cc.callFunc(function (target, param1) {
let nodeContainer = this.node.getChildByName('DataContainerMask').getChildByName('DataContainer');
for (let i = 0; i < iScrollRows * this._iCellCountEachRow; i++) { //这里不一定满的,根据查询结果可能不满一页的行数
////
let iIndexOfCellNeedAlpha = (this._iPFBIndexOfFirstCellInPage
+ this._iShowCellRows * 2 * this._iCellCountEachRow + i) //加一个是因为怕特殊情况变负的
% (this._iCellRowCount * this._iCellCountEachRow);
//新添加的部分 也要考虑Alpha太大的情况,防止底端穿孔到对面去
if (this._iRecordIndexOfFirstCellInPage
+ this._iShowCellRows * 2 * this._iCellCountEachRow + i < this._iRecordCount) {
let compCellNeedAlpha = nodeContainer.getChildByName(this._strListCellName + iIndexOfCellNeedAlpha).getComponent(ListCell);
compCellNeedAlpha.disableFocusInfo();
compCellNeedAlpha.node.opacity = 100;
} else {
let compCellNeedAlpha = nodeContainer.getChildByName(this._strListCellName + iIndexOfCellNeedAlpha).getComponent(ListCell);
compCellNeedAlpha.disableFocusInfo();
compCellNeedAlpha.node.opacity = 0;
}
//即使下方数据不满一行上面也要全部失效,整行的处理
let iIndexOfCellNeedHide = (this._iPFBIndexOfFirstCellInPage + i) % (this._iCellRowCount * this._iCellCountEachRow);
//cc.log(nodeContainer.getChildByName('ListCell'+iIndexOfCellNeedHide).name);
let compCellNeedHide = nodeContainer.getChildByName(this._strListCellName + iIndexOfCellNeedHide)
.getComponent(ListCell);
compCellNeedHide.disableFocusInfo();
compCellNeedHide.node.opacity = 0;
}
//飞完光标后把上下文都处理干净
this._iRecordIndexOfFirstCellInPage += (iScrollRows * this._iCellCountEachRow);
cc.log("this._iRecordIndexOfFirstCellInPage:" + this._iRecordIndexOfFirstCellInPage);
this._iPFBIndexOfFirstCellInPage = (this._iPFBIndexOfFirstCellInPage + iScrollRows * this._iCellCountEachRow)
% (this._iCellRowCount * this._iCellCountEachRow);
if (this._fnDataPositionRender && typeof this._fnDataPositionRender == 'function') {
this._fnDataPositionRender(this._iRecordIndexOfFirstCellInPage + 1, oJSONResult.count);
}
param1[0].onListScrollEnd && param1[0].onListScrollEnd();
}, this, [this._compSceneCanvas])
);
//动滑块
this.putScrollBarBlockInPosition(this._iRecordIndexOfFirstCellInPage + iScrollRows * this._iCellCountEachRow);
ftaSearchResultSequence.setTag(11);
nodeContainer.stopAction(nodeContainer.getActionByTag(11));
nodeContainer.runAction(ftaSearchResultSequence);
}, this);
cc.log("Business Success : SongList scrollAPageDown");
} else {
if (this._fnDataPositionRender && typeof this._fnDataPositionRender == 'function') {
this._fnDataPositionRender(0, 0);
}
cc.log("Business Error : DataList scrollAPageDown..." + oJSONResult.description);
}
} catch (ex) {
cc.log("Business Exception : DataList scrollAPageDown..." + ex);
}
},
function (strResponse) {
cc.log("Communication Error : DataList scrollAPageDown..." + strResponse);
},
this
);
return true;
},
decorate: function (aData) { //装饰
},
setCurrentFocus: function (_fiCurrentFocus) {
this._fiCurrentFocusNew = _fiCurrentFocus;
},
putScrollBarBlockInPosition: function (iRecordIndexOfFirstCellInPageAfterAnimation) { //计算绝对位置,防止半拉子事情发生
let iShowCellCount = this._iShowCellRows * this._iCellCountEachRow;
if (null == iRecordIndexOfFirstCellInPageAfterAnimation) {
iRecordIndexOfFirstCellInPageAfterAnimation = this._iRecordIndexOfFirstCellInPage;
}
let nodeScrollBarContainer = this.node.getChildByName('ScrollBarContainer');
let nodeScrollBarShadow = nodeScrollBarContainer.getChildByName('ScrollBarShadow');
let nodeScrollBarBlock = nodeScrollBarShadow.getChildByName('ScrollBarBlock');
let nodePage = nodeScrollBarBlock.getChildByName("Page");
let cFocus = this._compSceneCanvas.getFocus();
if (1 == this._iSwitchDirection) { //竖着
var iPreHeight = nodeScrollBarShadow.height;
if (nodePage) { //翻页文字竖着
nodePage.getComponent(cc.RichText).string = "翻\n页\n <color=#FFFF80>" + (Math.ceil(iRecordIndexOfFirstCellInPageAfterAnimation / (this._iShowCellRows * this._iCellCountEachRow)) + 1) + "</color>";
}
//TODO:_iRecordCount总记录数
let loc = ((iRecordIndexOfFirstCellInPageAfterAnimation + iShowCellCount > this._iRecordCount
? this._iRecordCount : iRecordIndexOfFirstCellInPageAfterAnimation + iShowCellCount) / this._iRecordCount) * (nodeScrollBarContainer.height - 94);
//---------------------补丁---------------------------
loc += 94;
// cc.log("//////////////////"+loc);
// if (loc <= 94) {
// loc = 94;
// }
//----------------------------------------------------
nodeScrollBarShadow.height = loc;
if (this._fiCurrentFocusNew && this._fiCurrentFocusNew.node.name == "ScrollBarBlock") {
cFocus.fly(this._fiCurrentFocusNew.getLeft(), this._fiCurrentFocusNew.getTop() + nodeScrollBarShadow.height - iPreHeight, this._fiCurrentFocusNew.getWidth(), this._fiCurrentFocusNew.getHeight(), Common.FOCUS_FLY_DURATION, 1.0);
}
} else {
var iPrevWidth = nodeScrollBarShadow.width;
if (nodePage) { //翻页文字横着
nodePage.getComponent(cc.RichText).string = "翻页 <color=#FFFF80>" + (Math.ceil(iRecordIndexOfFirstCellInPageAfterAnimation / (this._iShowCellRows * this._iCellCountEachRow)) + 1) + "</color>";
}
let loc = ((iRecordIndexOfFirstCellInPageAfterAnimation + iShowCellCount > this._iRecordCount
? this._iRecordCount : iRecordIndexOfFirstCellInPageAfterAnimation + iShowCellCount) / this._iRecordCount) * nodeScrollBarContainer.width;
nodeScrollBarShadow.width = loc;
if (this._fiCurrentFocusNew && this._fiCurrentFocusNew.node.name == "ScrollBarBlock") {
cFocus.fly(this._fiCurrentFocusNew.getLeft() + nodeScrollBarShadow.width - iPrevWidth, this._fiCurrentFocusNew.getTop(), this._fiCurrentFocusNew.getWidth(), this._fiCurrentFocusNew.getHeight(), Common.FOCUS_FLY_DURATION, 1.0);
}
}
},
hideCellOutOfDisplayArea: function () {//todo:这里呢觉得该隐藏掉的还是得隐藏掉,夜长梦多,mask要保持
let nodeContainer = this.node.getChildByName('DataContainerMask').getChildByName('DataContainer');
for (let i = 0; i < this._iShowCellRows * this._iCellCountEachRow; i++) {
let nodeCell = nodeContainer.getChildByName(this._strListCellName
+ ((this._iPFBIndexOfFirstCellInPage + (this._iShowCellRows + this._iAlphaCellRows) * this._iCellCountEachRow + i) % (this._iCellRowCount * this._iCellCountEachRow))); //这里第一次显示如果不是从头开始显示的,则要使用准确的PFB来操作
let compCell = nodeCell.getComponent(ListCell);
compCell.disableFocusInfo();
compCell.node.opacity = 0;
}
},
});