@cc-component/cc-ex-component 1.2.8 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/assets/core/BaseReference.ts +10 -1
  2. package/assets/core/BaseReference.ts.meta +1 -1
  3. package/assets/core/BaseViewModelData.ts.meta +1 -1
  4. package/assets/core/ReferenceComponent.ts +15 -9
  5. package/assets/core/ReferenceComponent.ts.meta +1 -1
  6. package/assets/core/ViewModel.ts +170 -171
  7. package/assets/core/ViewModel.ts.meta +1 -1
  8. package/assets/core.meta +1 -1
  9. package/assets/ex/EXButton.ts.meta +1 -1
  10. package/assets/ex/ExCommon.ts.meta +1 -1
  11. package/assets/ex/ExTool.ts.meta +1 -1
  12. package/assets/ex/ExTween.ts.meta +1 -1
  13. package/assets/ex.meta +1 -1
  14. package/assets/lib/collectView/lib-ext/custom-grid-flow-layout.ts.meta +1 -1
  15. package/assets/lib/collectView/lib-ext/horizontal-center-layout.ts.meta +1 -1
  16. package/assets/lib/collectView/lib-ext/yx-card-page-layout.ts.meta +1 -1
  17. package/assets/lib/collectView/lib-ext/yx-carousel-layout.ts.meta +1 -1
  18. package/assets/lib/collectView/lib-ext/yx-cover-layout.ts.meta +1 -1
  19. package/assets/lib/collectView/lib-ext/yx-masonry-flow-layout.ts.meta +1 -1
  20. package/assets/lib/collectView/lib-ext/yx-page-view.ts.meta +1 -1
  21. package/assets/lib/collectView/lib-ext/yx-table-view.ts.meta +1 -1
  22. package/assets/lib/collectView/lib-ext.meta +1 -1
  23. package/assets/lib/collectView/lib_collect/yx-collection-view.ts +14 -0
  24. package/assets/lib/collectView/lib_collect/yx-collection-view.ts.meta +1 -1
  25. package/assets/lib/collectView/lib_collect/yx-compact-flow-layout.ts.meta +1 -1
  26. package/assets/lib/collectView/lib_collect/yx-flow-layout.ts +12 -5
  27. package/assets/lib/collectView/lib_collect/yx-flow-layout.ts.meta +1 -1
  28. package/assets/lib/collectView/lib_collect/yx-page-layout.ts +100 -0
  29. package/assets/lib/collectView/lib_collect/yx-page-layout.ts.meta +9 -0
  30. package/assets/lib/collectView/lib_collect/yx-table-layout.ts.meta +1 -1
  31. package/assets/lib/collectView/lib_collect.meta +1 -1
  32. package/assets/lib/collectView.meta +1 -1
  33. package/assets/lib/tableView/IListView.ts.meta +1 -1
  34. package/assets/lib/tableView/ListView.ts +1 -1
  35. package/assets/lib/tableView/ListView.ts.meta +1 -1
  36. package/assets/lib/tableView/ListViewPage.ts +56 -20
  37. package/assets/lib/tableView/ListViewPage.ts.meta +1 -1
  38. package/assets/lib/tableView/ListViewPageLoop.ts +1 -1
  39. package/assets/lib/tableView/ListViewPageLoop.ts.meta +1 -1
  40. package/assets/lib/tableView/TableView.ts +22 -2
  41. package/assets/lib/tableView/TableView.ts.meta +1 -1
  42. package/assets/lib/tableView.meta +1 -1
  43. package/assets/lib.meta +1 -1
  44. package/assets.meta +1 -1
  45. package/index.ts.meta +1 -1
  46. package/package.json +1 -1
  47. package/package.json.meta +1 -1
package/assets/core.meta CHANGED
@@ -2,7 +2,7 @@
2
2
  "ver": "1.2.0",
3
3
  "importer": "directory",
4
4
  "imported": true,
5
- "uuid": "0845ba86-7f8a-4a17-9396-fe31fbd7d13d",
5
+ "uuid": "77f548dd-1d1c-4d91-9bee-11ec6b75bc8c",
6
6
  "files": [],
7
7
  "subMetas": {},
8
8
  "userData": {}
@@ -2,7 +2,7 @@
2
2
  "ver": "4.0.24",
3
3
  "importer": "typescript",
4
4
  "imported": true,
5
- "uuid": "09077e2c-d1d5-47dd-878c-53a2d7d27615",
5
+ "uuid": "d2fece30-253f-4398-8303-f190f71e7c52",
6
6
  "files": [],
7
7
  "subMetas": {},
8
8
  "userData": {}
@@ -2,7 +2,7 @@
2
2
  "ver": "4.0.24",
3
3
  "importer": "typescript",
4
4
  "imported": true,
5
- "uuid": "2114b6dd-3bd1-43c6-8bbd-7de5eee953b2",
5
+ "uuid": "ec909568-5abb-4789-99c8-a390b68ab971",
6
6
  "files": [],
7
7
  "subMetas": {},
8
8
  "userData": {}
@@ -2,7 +2,7 @@
2
2
  "ver": "4.0.24",
3
3
  "importer": "typescript",
4
4
  "imported": true,
5
- "uuid": "4651c916-7849-4828-8b1f-8ec8e6700870",
5
+ "uuid": "3f3cc171-4aad-4687-829c-0ac8d8940e35",
6
6
  "files": [],
7
7
  "subMetas": {},
8
8
  "userData": {}
@@ -2,7 +2,7 @@
2
2
  "ver": "4.0.24",
3
3
  "importer": "typescript",
4
4
  "imported": true,
5
- "uuid": "24e7cfb8-9b50-466d-98d7-937a8be553c6",
5
+ "uuid": "efa7ec08-ffdd-47a1-8207-442d4adc469d",
6
6
  "files": [],
7
7
  "subMetas": {},
8
8
  "userData": {}
package/assets/ex.meta CHANGED
@@ -2,7 +2,7 @@
2
2
  "ver": "1.2.0",
3
3
  "importer": "directory",
4
4
  "imported": true,
5
- "uuid": "f84c6b5c-beb1-4d53-a029-e4db3b753558",
5
+ "uuid": "e094bead-f297-46cc-bcef-4d054ce1be6a",
6
6
  "files": [],
7
7
  "subMetas": {},
8
8
  "userData": {}
@@ -2,7 +2,7 @@
2
2
  "ver": "4.0.24",
3
3
  "importer": "typescript",
4
4
  "imported": true,
5
- "uuid": "05c078a1-40ab-42df-8513-cba6085ed148",
5
+ "uuid": "4d3e29a8-88e3-43b9-97b6-9d32ef3891d2",
6
6
  "files": [],
7
7
  "subMetas": {},
8
8
  "userData": {}
@@ -2,7 +2,7 @@
2
2
  "ver": "4.0.24",
3
3
  "importer": "typescript",
4
4
  "imported": true,
5
- "uuid": "5e1959e8-513f-4b10-87fa-a27440b8dcc8",
5
+ "uuid": "3e108a0c-8d37-43f9-80f9-5d7db40fc244",
6
6
  "files": [],
7
7
  "subMetas": {},
8
8
  "userData": {}
@@ -2,7 +2,7 @@
2
2
  "ver": "4.0.24",
3
3
  "importer": "typescript",
4
4
  "imported": true,
5
- "uuid": "51c366be-372c-4db4-b338-ead340893f2d",
5
+ "uuid": "d28d03a6-ab2e-4025-9e0c-75375cae0098",
6
6
  "files": [],
7
7
  "subMetas": {},
8
8
  "userData": {}
@@ -2,7 +2,7 @@
2
2
  "ver": "4.0.24",
3
3
  "importer": "typescript",
4
4
  "imported": true,
5
- "uuid": "d84704bd-3a9d-44fb-b239-1c9b988b73ff",
5
+ "uuid": "ada9f67b-b459-4f5b-8589-6760503dab67",
6
6
  "files": [],
7
7
  "subMetas": {},
8
8
  "userData": {}
@@ -2,7 +2,7 @@
2
2
  "ver": "4.0.24",
3
3
  "importer": "typescript",
4
4
  "imported": true,
5
- "uuid": "ad37dbe1-7008-4cc8-939a-dab5bbb38b08",
5
+ "uuid": "66a4f141-18d1-4bed-be87-785162a887e2",
6
6
  "files": [],
7
7
  "subMetas": {},
8
8
  "userData": {}
@@ -2,7 +2,7 @@
2
2
  "ver": "4.0.24",
3
3
  "importer": "typescript",
4
4
  "imported": true,
5
- "uuid": "2b51d44c-785f-4b16-82e2-b42cb9c0a5d8",
5
+ "uuid": "3568a308-d477-4e2c-8f67-338d98bd0237",
6
6
  "files": [],
7
7
  "subMetas": {},
8
8
  "userData": {}
@@ -2,7 +2,7 @@
2
2
  "ver": "4.0.24",
3
3
  "importer": "typescript",
4
4
  "imported": true,
5
- "uuid": "96dd5e9a-3b90-4699-9733-0ffc540be67f",
5
+ "uuid": "079fb0c9-3ce3-46eb-af24-7d1e74d3745c",
6
6
  "files": [],
7
7
  "subMetas": {},
8
8
  "userData": {}
@@ -2,7 +2,7 @@
2
2
  "ver": "4.0.24",
3
3
  "importer": "typescript",
4
4
  "imported": true,
5
- "uuid": "4fddde1e-ca59-4a70-9721-20f26a5c017e",
5
+ "uuid": "8de1e72f-3061-428b-82e1-d99d9b7bcbf1",
6
6
  "files": [],
7
7
  "subMetas": {},
8
8
  "userData": {}
@@ -2,7 +2,7 @@
2
2
  "ver": "1.2.0",
3
3
  "importer": "directory",
4
4
  "imported": true,
5
- "uuid": "193633f9-e511-492f-b2f9-38e6527e2ed2",
5
+ "uuid": "2a529d56-d008-4307-b2f2-5deb375ff332",
6
6
  "files": [],
7
7
  "subMetas": {},
8
8
  "userData": {}
@@ -522,6 +522,20 @@ export abstract class YXLayout {
522
522
  * 列表组件销毁时执行
523
523
  */
524
524
  onDestroy() { }
525
+
526
+
527
+ //#region 新加
528
+ /**
529
+ * 转换为真实索引
530
+ * 列表数量大小为 3 倍实际数据数量,需要通过求余方式获取数据,避免数组越界
531
+ */
532
+ dataCount: number = 0
533
+ originIndex(index: number): number {
534
+ return 0
535
+ }
536
+ originIndexCount(): number {
537
+ return this.dataCount * 3
538
+ }
525
539
  }
526
540
 
527
541
  /**
@@ -2,7 +2,7 @@
2
2
  "ver": "4.0.24",
3
3
  "importer": "typescript",
4
4
  "imported": true,
5
- "uuid": "f2c14ab4-51e7-4ea7-ba67-5882a26bc0be",
5
+ "uuid": "352eb44c-0685-4ca4-89fe-eb7f8ff9d3d2",
6
6
  "files": [],
7
7
  "subMetas": {},
8
8
  "userData": {}
@@ -2,7 +2,7 @@
2
2
  "ver": "4.0.24",
3
3
  "importer": "typescript",
4
4
  "imported": true,
5
- "uuid": "6aefb187-febc-4916-93a9-f062e3bdd1f5",
5
+ "uuid": "91bfa62d-5f91-480a-b779-5c2973516c21",
6
6
  "files": [],
7
7
  "subMetas": {},
8
8
  "userData": {}
@@ -100,11 +100,18 @@ enum _yx_flow_layout_section_kinds {
100
100
  */
101
101
  export class YXFlowLayout extends YXBinaryLayout {
102
102
 
103
- /**
104
- * 是否开启分页滚动效果
105
- */
106
- pagingEnabled: boolean = false
107
103
 
104
+ // pagingEnabled: boolean = false
105
+ _pagingEnabled: boolean = false
106
+ set pagingEnabled(value: boolean) {
107
+ this._pagingEnabled = value
108
+ }
109
+ /**
110
+ * 是否开启分页滚动效果
111
+ */
112
+ get pagingEnabled() {
113
+ return this._pagingEnabled
114
+ }
108
115
  /**
109
116
  * 分页吸附动画时间
110
117
  */
@@ -119,7 +126,7 @@ export class YXFlowLayout extends YXBinaryLayout {
119
126
  /**
120
127
  * 约束优先级
121
128
  */
122
- priority: _yx_flow_layout_priority = YXFlowLayout.Priority.LEFT
129
+ priority: _yx_flow_layout_priority = YXFlowLayout.Priority.SIDE
123
130
  static Priority = _yx_flow_layout_priority
124
131
 
125
132
  /**
@@ -2,7 +2,7 @@
2
2
  "ver": "4.0.24",
3
3
  "importer": "typescript",
4
4
  "imported": true,
5
- "uuid": "238e51fb-2279-4282-9d75-a8eea31ff882",
5
+ "uuid": "2c724001-1f7c-489f-b6da-519cb9277026",
6
6
  "files": [],
7
7
  "subMetas": {},
8
8
  "userData": {}
@@ -0,0 +1,100 @@
1
+ import { ScrollView } from "cc";
2
+ import { YXFlowLayout } from "./yx-flow-layout";
3
+ import { YXCollectionView, YXIndexPath } from "./yx-collection-view";
4
+ import { math } from "cc";
5
+
6
+
7
+ export class YXPagelayout extends YXFlowLayout {
8
+
9
+ _pagingEnabledLoop = false
10
+ set pagingEnabledLoop(value: boolean) {
11
+ this._pagingEnabledLoop = value
12
+ }
13
+ get pagingEnabledLoop() {
14
+ return this._pagingEnabledLoop
15
+ }
16
+ /**
17
+ * 记录当前页面
18
+ */
19
+ pageIdx: number = -1
20
+
21
+ collectionView: YXCollectionView
22
+ scrollView: ScrollView;
23
+ dataCount: number = 0
24
+
25
+
26
+ pageAction: (idx: number) => void
27
+ loop(collectionView: YXCollectionView) {
28
+ /**
29
+ * 无限轮播实现思路
30
+ * 列表容器总体大小为 数据条数 * 3 的大小,每次在滚动结束的时候,偏移量总是复位到中间的位置,以此来实现无限滚动
31
+ * 比如原始数据 [ 0,1,2 ],实际上在列表中为 [ 0,1,2, 0,1,2, 0,1,2 ],每次滑动结束之后位置总是复位到中间区域
32
+ */
33
+
34
+ // 注册列表内需要使用的 cell 节点类型
35
+ // 这个演示是通过编辑器绑定的,可以查看场景内 list 节点里的 register cells 配置
36
+ // this.listComp.register(`cell`, () => instantiate('your cell prefab'))
37
+ this.collectionView = collectionView
38
+ this.scrollView = collectionView.scrollView
39
+ this.scrollView.node.on(ScrollView.EventType.SCROLLING, this.checkPageChange, this)
40
+ this.scrollView.node.on(ScrollView.EventType.SCROLL_ENDED, this.resetOffset, this)
41
+ this.pagingEnabled = true;
42
+ this.collectionView.recycleInterval = 0
43
+ }
44
+
45
+ onDestroy(): void {
46
+ this.scrollView.node.off(ScrollView.EventType.SCROLLING, this.checkPageChange, this)
47
+ this.scrollView.node.off(ScrollView.EventType.SCROLL_ENDED, this.resetOffset, this)
48
+ }
49
+
50
+ /**
51
+ * 获取当前页面索引
52
+ * @returns
53
+ */
54
+ getCurrentPageIndex(): number {
55
+ let offset = this.collectionView.scrollView.getScrollOffset()
56
+ offset.x = - offset.x
57
+ let idx = Math.round(offset.x / this.collectionView.scrollView.view.width)
58
+ return idx
59
+ }
60
+
61
+ /**
62
+ * 检查页面变化
63
+ */
64
+ checkPageChange() {
65
+ const idx = this.getCurrentPageIndex()
66
+ if (this.pageIdx !== idx) {
67
+ this.pageIdx = idx
68
+ // 走到这里表示页面发生变化,可以处理需要处理的逻辑
69
+ this.pageAction && this.pageAction(this.originIndex(this.pageIdx))
70
+ console.log(this.originIndex(this.pageIdx));
71
+
72
+ }
73
+ }
74
+
75
+ /**
76
+ * 使列表复位到中间区域
77
+ */
78
+ resetOffset() {
79
+ let offset = this.scrollView.getScrollOffset()
80
+ offset.x = - offset.x
81
+ let idx = Math.round(offset.x / this.scrollView.view.width) % this.dataCount
82
+ offset.x = this.scrollView.view.width * (this.dataCount + idx)
83
+ this.scrollView.scrollToOffset(offset)
84
+ // 直接设置滚动位置不会触发刷新,这里强制刷新一下
85
+ this.collectionView.markForUpdateVisibleData(true)
86
+ }
87
+
88
+ /**
89
+ * 转换为真实索引
90
+ * 列表数量大小为 3 倍实际数据数量,需要通过求余方式获取数据,避免数组越界
91
+ */
92
+ originIndex(index: number): number {
93
+ return index % this.dataCount
94
+ }
95
+ originIndexCount(): number {
96
+ return this.dataCount * 3
97
+ }
98
+ }
99
+
100
+
@@ -0,0 +1,9 @@
1
+ {
2
+ "ver": "4.0.24",
3
+ "importer": "typescript",
4
+ "imported": true,
5
+ "uuid": "87fa13ef-d7dc-45d1-95bf-e86380461ad1",
6
+ "files": [],
7
+ "subMetas": {},
8
+ "userData": {}
9
+ }
@@ -2,7 +2,7 @@
2
2
  "ver": "4.0.24",
3
3
  "importer": "typescript",
4
4
  "imported": true,
5
- "uuid": "952a15e3-b44b-49eb-b09c-df418ba5a6c3",
5
+ "uuid": "0427cc26-ec7a-4bc5-9003-45aba5afc1c6",
6
6
  "files": [],
7
7
  "subMetas": {},
8
8
  "userData": {}
@@ -2,7 +2,7 @@
2
2
  "ver": "1.2.0",
3
3
  "importer": "directory",
4
4
  "imported": true,
5
- "uuid": "1bb2bf39-991d-44bf-85d0-fdfc16f4144d",
5
+ "uuid": "00414583-fed7-4ac2-bf99-d5441b807c9f",
6
6
  "files": [],
7
7
  "subMetas": {},
8
8
  "userData": {}
@@ -2,7 +2,7 @@
2
2
  "ver": "1.2.0",
3
3
  "importer": "directory",
4
4
  "imported": true,
5
- "uuid": "3e16331d-321f-4cff-86f3-d1740e9f5915",
5
+ "uuid": "09765a3f-0e8f-4c97-b88d-6b3080a9fe36",
6
6
  "files": [],
7
7
  "subMetas": {},
8
8
  "userData": {}
@@ -2,7 +2,7 @@
2
2
  "ver": "4.0.24",
3
3
  "importer": "typescript",
4
4
  "imported": true,
5
- "uuid": "afcba0d7-2455-45d3-af24-db4650301eb6",
5
+ "uuid": "0d4ca83f-8618-44b3-828e-2779e8461bcc",
6
6
  "files": [],
7
7
  "subMetas": {},
8
8
  "userData": {}
@@ -82,7 +82,7 @@ export class scroll_config {
82
82
  })
83
83
  cellSpaceRight: number = 20
84
84
 
85
- @property({ displayName: `整页滚动>>>>` })
85
+ @property({ displayName: `整页滚动`, tooltip: `需要设置左右间距:总宽ContentSize/2-cell宽/2` })
86
86
  isPage: boolean = false
87
87
 
88
88
  @property({
@@ -2,7 +2,7 @@
2
2
  "ver": "4.0.24",
3
3
  "importer": "typescript",
4
4
  "imported": true,
5
- "uuid": "cacea2ef-1572-4b38-94fc-71ca11e3709e",
5
+ "uuid": "add3416e-7ce8-4ebe-a63b-e4badaece0c9",
6
6
  "files": [],
7
7
  "subMetas": {},
8
8
  "userData": {}
@@ -28,7 +28,7 @@ export class ListViewPage extends ListView {
28
28
  this.node.on(ScrollView.EventType.SCROLL_BEGAN, this.onTouchStart, this);
29
29
  this.node.on(ScrollView.EventType.TOUCH_UP, this.onTouchEnd, this);
30
30
  this.node.on(ScrollView.EventType.SCROLLING, this._scrollViewDidScroll, this);
31
- this.node.on(Node.EventType.TOUCH_CANCEL, this.onTouchEnd, this);
31
+ this.node.on(Node.EventType.TOUCH_CANCEL, this.onTouchCancel, this);
32
32
 
33
33
  //ScrollView.EventType
34
34
  }
@@ -83,7 +83,9 @@ export class ListViewPage extends ListView {
83
83
  this.content = content
84
84
  viewMask.getComponent(Widget).updateAlignment()
85
85
  }
86
+
86
87
  this.contentUT = this.content.getComponent(UITransform)
88
+ let count = 0
87
89
  if (this.config.scrollDirection === collection_view_scroll_direction.HORIZONTAL) {
88
90
  this.contentUT.anchorX = this.config.isLoop ? 0.5 : 0
89
91
  this.contentUT.anchorY = 0.5
@@ -91,10 +93,13 @@ export class ListViewPage extends ListView {
91
93
  this.contentUT.anchorX = 0.5
92
94
  this.contentUT.anchorY = this.config.isLoop ? 0.5 : 1
93
95
  }
96
+
94
97
  this.nodeUT.setAnchorPoint(0.5, 0.5)
95
98
  const mask_node = this.content.parent.getComponent(UITransform)
96
99
  this.contentUT.contentSize = new Size(mask_node.width, mask_node.height)
97
100
  this.scrollTo(v2(0))
101
+
102
+
98
103
  }
99
104
  initView() {
100
105
  if (this.config.scrollDirection === collection_view_scroll_direction.HORIZONTAL) {
@@ -119,7 +124,7 @@ export class ListViewPage extends ListView {
119
124
  this.node.off(Node.EventType.TOUCH_START, this.onTouchStart, this);
120
125
  this.node.off(Node.EventType.TOUCH_MOVE, this.onTouchMove, this);
121
126
  this.node.off(Node.EventType.TOUCH_END, this.onTouchEnd, this);
122
- this.node.off(Node.EventType.TOUCH_CANCEL, this.onTouchEnd, this);
127
+ this.node.off(Node.EventType.TOUCH_CANCEL, this.onTouchCancel, this);
123
128
 
124
129
  }
125
130
 
@@ -208,6 +213,7 @@ export class ListViewPage extends ListView {
208
213
 
209
214
 
210
215
  _reloadData() {
216
+ this.stopAutoScroll()
211
217
  let numberOfItems = this.delegate.numberOfItems();
212
218
  this.numberOfItems = numberOfItems;
213
219
 
@@ -235,7 +241,7 @@ export class ListViewPage extends ListView {
235
241
  }
236
242
  let offsetMax = this.getMaxScrollOffset();
237
243
 
238
- this.stopAutoScroll()
244
+
239
245
 
240
246
  this.scrollToOffset(v2(-offset.x, offset.y))
241
247
  this.isReload = true;
@@ -296,6 +302,7 @@ export class ListViewPage extends ListView {
296
302
  start_pos = this.getShowRowListPos()
297
303
 
298
304
  this.visbleCellList.forEach((cell, index) => {
305
+ console.log(`cell.row:${cell.row_data},${cell.row}`)
299
306
  let x = 0;
300
307
  if (lastCell) {
301
308
  if (this.config.scrollDirection === collection_view_scroll_direction.HORIZONTAL) {
@@ -358,27 +365,40 @@ export class ListViewPage extends ListView {
358
365
  target_pos = v3(0, 0, 0)
359
366
  currentRow = 0
360
367
  }
368
+
361
369
  const count = Math.max(showChount - (showChount - currentRow), 0);
362
370
 
363
371
  const width = this.getWidth() + this.config.cellSpace;
364
372
  const max_height = width * count
365
373
  let start = 0
366
374
  if (this.config.scrollDirection === collection_view_scroll_direction.HORIZONTAL) {
367
- start = (target_pos.x - max_height)
368
- if (start <= 0) {
369
- start = start + this.getWidth() * 0.5
375
+ if (target_pos) {
376
+
377
+ start = (target_pos.x - max_height)
378
+ // if (max_height === 0) { start = 0 }
379
+ if (start <= 0) {
380
+ start = start + this.getWidth() * 0.5
381
+ }
382
+ if (this.lastCellCount <= 0) {
383
+ start += this.config.cellSpaceLeft
384
+ }
370
385
  }
371
- if (this.lastCellCount <= 0) {
372
- start += this.config.cellSpaceLeft
386
+ else {
387
+ start += this.config.cellSpaceLeft + this.getWidth() * 0.5
373
388
  }
374
389
  } else {
375
- start = (target_pos.y + max_height)
376
- if (start >= 0) {
377
- start = start - this.getWidth() * 0.5
378
- }
379
- if (this.lastCellCount <= 0) {
380
- start -= this.config.cellSpaceLeft
390
+ if (target_pos) {
391
+ start = (target_pos.y + max_height)
392
+ if (start >= 0) {
393
+ start = start - this.getWidth() * 0.5
394
+ }
395
+ if (this.lastCellCount <= 0) {
396
+ start -= this.config.cellSpaceLeft
397
+ }
398
+ } else {
399
+ start += this.config.cellSpaceLeft + this.getWidth() * 0.5
381
400
  }
401
+
382
402
  }
383
403
 
384
404
  return start
@@ -392,13 +412,12 @@ export class ListViewPage extends ListView {
392
412
  const count_n = this.numberOfItems - this.max_row_data;
393
413
  let row = count_n > 0 ? this.min_row_data : Math.max(this.min_row_data - (-count_n + 1), 0)
394
414
  if (this.visbleCellList.length > 0) {
395
- if (this.numberOfItems > this.config.maxShowCount &&
396
- this.currentRow < this.numberOfItems - 1 &&
397
- this.max_row_data + 1 < this.numberOfItems &&
415
+ const ok_1 = this.numberOfItems > this.config.maxShowCount
416
+ const ok_2 = this.currentRow < this.numberOfItems - 1
417
+ const ok_3 = this.max_row_data + 1 < this.numberOfItems
418
+ const ok_4 = (this.currentRow === this.visbleCellList[this.visbleCellList.length - 1].row_data || this.currentRow === this.visbleCellList[this.visbleCellList.length - 2].row_data)
398
419
 
399
- (this.currentRow === this.visbleCellList[this.visbleCellList.length - 1].row_data ||
400
- this.currentRow === this.visbleCellList[this.visbleCellList.length - 2].row_data)
401
- ) {
420
+ if (ok_1 && ok_2 && ok_3 && ok_4 && row != 0) {
402
421
  row += 1;
403
422
  this.max_row_data += 1
404
423
  //console.error("走了", this.max_row_data)
@@ -457,6 +476,22 @@ export class ListViewPage extends ListView {
457
476
  this.touchEnd(event, false)
458
477
  }
459
478
 
479
+ }
480
+ onTouchCancel(event: EventTouch) {
481
+
482
+ if (this.config.isPage)
483
+ this.onTouchEnd(event)
484
+
485
+ // const of = this.getScrollOffset()
486
+ // if (this.config.scrollDirection === collection_view_scroll_direction.HORIZONTAL) {
487
+ // if (of.x < 0)
488
+ // this.onTouchEnd(event)
489
+ // } else {
490
+ // if (of.x < 0)
491
+ // this.onTouchEnd(event)
492
+ // }
493
+
494
+
460
495
  }
461
496
 
462
497
  touchEnd(event: EventTouch, isInit) {
@@ -637,6 +672,7 @@ export class ListViewPage extends ListView {
637
672
  _scrollViewDidScrollPage(is_move = false) {
638
673
  this._updateMaxNode()
639
674
  const of = this.getScrollOffset();
675
+ // console.log(of)
640
676
  if (this.config.scrollDirection === collection_view_scroll_direction.HORIZONTAL) {
641
677
  this.velocity = Math.abs((of.x - this.lastOffset.x))
642
678
  } else {
@@ -2,7 +2,7 @@
2
2
  "ver": "4.0.24",
3
3
  "importer": "typescript",
4
4
  "imported": true,
5
- "uuid": "d69a9fe3-2e65-4fd2-81a9-ee7a87a8d164",
5
+ "uuid": "abcfd5c6-dab6-4a9d-950f-a966fe3804ef",
6
6
  "files": [],
7
7
  "subMetas": {},
8
8
  "userData": {}
@@ -584,7 +584,7 @@ export class ListViewPageLoop extends ListView {
584
584
  this.currentRow = this.maxNode.row_data;
585
585
 
586
586
  } else {
587
- console.error("没有")
587
+ //console.error("没有")
588
588
  }
589
589
  }
590
590
  _scrollViewDidScrollPage(is_move: boolean = false) {
@@ -1 +1 @@
1
- {"ver":"4.0.24","importer":"typescript","imported":true,"uuid":"75405e06-7406-42a4-9fbd-3bc9aac788d4","files":[],"subMetas":{},"userData":{}}
1
+ {"ver":"4.0.24","importer":"typescript","imported":true,"uuid":"76830660-44be-4583-804a-12c8c9b6f838","files":[],"subMetas":{},"userData":{}}
@@ -33,29 +33,49 @@ export class TableView extends Component {
33
33
  return this.delegate ? true : false;
34
34
  }
35
35
  finish: Function;
36
+ isOnload = false;
36
37
  // view: Node;
37
38
  protected onLoad(): void {
38
39
  if (this.config.isLoop) {
39
40
  this.scrollView = this.node.addComponent(ListViewPageLoop)
41
+ this.scrollView.elastic = false
40
42
  } else {
41
43
  this.scrollView = this.node.addComponent(ListViewPage)
44
+ this.scrollView.elastic = this.config.isPage ? false : true
42
45
  }
43
46
  this.scrollView.elastic = false
47
+
44
48
  this.scrollView.delegate = this.delegate;
45
49
  this.scrollView.config = this.config;
46
50
  this.scrollView.init();
47
- this.finish?.()
51
+ this.isOnload = true
52
+ if (this.finish) {
53
+ this.finish()
54
+ }
55
+
48
56
  }
49
57
  init(delegate: IListView) {
50
58
  this.delegate = delegate
51
59
  //解决一些设置时间点慢的问题
52
60
  if (this.scrollView) {
53
61
  this.scrollView.delegate = delegate
62
+ const itemSize = this.delegate.itemSize();
63
+ let count = 0
64
+ if (this.config.scrollDirection === collection_view_scroll_direction.HORIZONTAL) {
65
+ count = this.scrollView.nodeUT.width / (itemSize.width + this.config.cellSpace)//+ this.config.cellSpaceLeft + this.config.cellSpaceRight
66
+ } else {
67
+ count = this.scrollView.nodeUT.height / (itemSize.height + this.config.cellSpace)//+ this.config.cellSpaceLeft + this.config.cellSpaceRight
68
+ }
69
+ this.config.maxShowCount = Math.max(Math.floor(count) + 3, this.config.maxShowCount)
70
+ console.log("maxShowCount", this.config.maxShowCount)
54
71
  }
55
-
56
72
  }
57
73
  onLoadFinish(call: () => void) {
58
74
  this.finish = call
75
+ if (this.isOnload) {
76
+ this.finish?.()
77
+ this.finish = null
78
+ }
59
79
  }
60
80
 
61
81
  public reload() {