mirror of
https://github.com/Leo501/CocosCreatorTutorial.git
synced 2026-05-07 22:27:22 +08:00
ListView, 循环滚动列表,固定尺寸item, 屏幕可见范围外item会回收等待下次复用。支持横向,竖向,多行多列。支持追加删除数据。支持上右下左padding, 支持设置item锚点
This commit is contained in:
67
ListViewV2Demo/.gitignore
vendored
Normal file
67
ListViewV2Demo/.gitignore
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
# Fireball Projects
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
library/
|
||||
temp/
|
||||
local/
|
||||
build/
|
||||
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
# Logs and databases
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
*.log
|
||||
*.sql
|
||||
*.sqlite
|
||||
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
# files for debugger
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
*.sln
|
||||
*.csproj
|
||||
*.pidb
|
||||
*.unityproj
|
||||
*.suo
|
||||
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
# OS generated files
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
.DS_Store
|
||||
ehthumbs.db
|
||||
Thumbs.db
|
||||
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
# exvim files
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
*UnityVS.meta
|
||||
*.err
|
||||
*.err.meta
|
||||
*.exvim
|
||||
*.exvim.meta
|
||||
*.vimentry
|
||||
*.vimentry.meta
|
||||
*.vimproject
|
||||
*.vimproject.meta
|
||||
.vimfiles.*/
|
||||
.exvim.*/
|
||||
quick_gen_project_*_autogen.bat
|
||||
quick_gen_project_*_autogen.bat.meta
|
||||
quick_gen_project_*_autogen.sh
|
||||
quick_gen_project_*_autogen.sh.meta
|
||||
.exvim.app
|
||||
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
# webstorm files
|
||||
#/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
.idea/
|
||||
|
||||
#//////////////////////////
|
||||
# VS Code
|
||||
#//////////////////////////
|
||||
|
||||
.vscode/
|
||||
5
ListViewV2Demo/README.md
Normal file
5
ListViewV2Demo/README.md
Normal file
@@ -0,0 +1,5 @@
|
||||
# ListView
|
||||
### ListView, 循环滚动列表,固定尺寸item, 屏幕可见范围外item会回收等待下次复用。支持横向,竖向,多行多列。支持追加删除数据。支持上右下左padding, 支持设置item锚点。
|
||||
### 有js/ts版本
|
||||
### 参数
|
||||
* https://github.com/caochao/cocos_creator_proj_base
|
||||
5
ListViewV2Demo/assets/Prefab.meta
Normal file
5
ListViewV2Demo/assets/Prefab.meta
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"ver": "1.0.1",
|
||||
"uuid": "8595fe16-47d7-49b7-aa15-9d29836a692d",
|
||||
"subMetas": {}
|
||||
}
|
||||
272
ListViewV2Demo/assets/Prefab/ListviewItem.prefab
Normal file
272
ListViewV2Demo/assets/Prefab/ListviewItem.prefab
Normal file
@@ -0,0 +1,272 @@
|
||||
[
|
||||
{
|
||||
"__type__": "cc.Prefab",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"_rawFiles": null,
|
||||
"data": {
|
||||
"__id__": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "ListviewItem",
|
||||
"_objFlags": 0,
|
||||
"_parent": null,
|
||||
"_children": [
|
||||
{
|
||||
"__id__": 2
|
||||
},
|
||||
{
|
||||
"__id__": 5
|
||||
}
|
||||
],
|
||||
"_tag": -1,
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 8
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 9
|
||||
},
|
||||
"_id": "",
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 255,
|
||||
"g": 255,
|
||||
"b": 255,
|
||||
"a": 255
|
||||
},
|
||||
"_cascadeOpacityEnabled": true,
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0.5,
|
||||
"y": 0.5
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 195,
|
||||
"height": 270
|
||||
},
|
||||
"_rotationX": 0,
|
||||
"_rotationY": 0,
|
||||
"_scaleX": 1,
|
||||
"_scaleY": 1,
|
||||
"_position": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"_skewX": 0,
|
||||
"_skewY": 0,
|
||||
"_localZOrder": 0,
|
||||
"_globalZOrder": 0,
|
||||
"_opacityModifyRGB": false,
|
||||
"groupIndex": 0
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "cocos",
|
||||
"_objFlags": 0,
|
||||
"_parent": {
|
||||
"__id__": 1
|
||||
},
|
||||
"_children": [],
|
||||
"_tag": -1,
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 3
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 4
|
||||
},
|
||||
"_id": "",
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 255,
|
||||
"g": 255,
|
||||
"b": 255,
|
||||
"a": 255
|
||||
},
|
||||
"_cascadeOpacityEnabled": true,
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0.5,
|
||||
"y": 0.5
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 195,
|
||||
"height": 270
|
||||
},
|
||||
"_rotationX": 0,
|
||||
"_rotationY": 0,
|
||||
"_scaleX": 1,
|
||||
"_scaleY": 1,
|
||||
"_position": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"_skewX": 0,
|
||||
"_skewY": 0,
|
||||
"_localZOrder": 0,
|
||||
"_globalZOrder": 0,
|
||||
"_opacityModifyRGB": false,
|
||||
"groupIndex": 0
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Sprite",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 2
|
||||
},
|
||||
"_enabled": true,
|
||||
"_spriteFrame": {
|
||||
"__uuid__": "31bc895a-c003-4566-a9f3-2e54ae1c17dc"
|
||||
},
|
||||
"_type": 0,
|
||||
"_sizeMode": 1,
|
||||
"_fillType": 0,
|
||||
"_fillCenter": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"_fillStart": 0,
|
||||
"_fillRange": 0,
|
||||
"_isTrimmedMode": true,
|
||||
"_srcBlendFactor": 770,
|
||||
"_dstBlendFactor": 771,
|
||||
"_atlas": null
|
||||
},
|
||||
{
|
||||
"__type__": "cc.PrefabInfo",
|
||||
"root": {
|
||||
"__id__": 1
|
||||
},
|
||||
"asset": {
|
||||
"__uuid__": "10c60cf0-420d-41d3-b409-ae1ebad07af7"
|
||||
},
|
||||
"fileId": "c4f30YOS65G64U2TwufdJ+2",
|
||||
"sync": false
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "label",
|
||||
"_objFlags": 0,
|
||||
"_parent": {
|
||||
"__id__": 1
|
||||
},
|
||||
"_children": [],
|
||||
"_tag": -1,
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 6
|
||||
}
|
||||
],
|
||||
"_prefab": {
|
||||
"__id__": 7
|
||||
},
|
||||
"_id": "",
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 255,
|
||||
"g": 255,
|
||||
"b": 255,
|
||||
"a": 255
|
||||
},
|
||||
"_cascadeOpacityEnabled": true,
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0.5,
|
||||
"y": 0.5
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 7,
|
||||
"height": 20
|
||||
},
|
||||
"_rotationX": 0,
|
||||
"_rotationY": 0,
|
||||
"_scaleX": 1,
|
||||
"_scaleY": 1,
|
||||
"_position": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0,
|
||||
"y": -57
|
||||
},
|
||||
"_skewX": 0,
|
||||
"_skewY": 0,
|
||||
"_localZOrder": 0,
|
||||
"_globalZOrder": 0,
|
||||
"_opacityModifyRGB": false,
|
||||
"groupIndex": 0
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Label",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 5
|
||||
},
|
||||
"_enabled": true,
|
||||
"_useOriginalSize": false,
|
||||
"_actualFontSize": 20,
|
||||
"_fontSize": 20,
|
||||
"_lineHeight": 20,
|
||||
"_enableWrapText": true,
|
||||
"_N$file": null,
|
||||
"_isSystemFontUsed": true,
|
||||
"_spacingX": 0,
|
||||
"_N$string": "-",
|
||||
"_N$horizontalAlign": 1,
|
||||
"_N$verticalAlign": 1,
|
||||
"_N$fontFamily": "Arial",
|
||||
"_N$overflow": 0
|
||||
},
|
||||
{
|
||||
"__type__": "cc.PrefabInfo",
|
||||
"root": {
|
||||
"__id__": 1
|
||||
},
|
||||
"asset": {
|
||||
"__uuid__": "10c60cf0-420d-41d3-b409-ae1ebad07af7"
|
||||
},
|
||||
"fileId": "31f1bH7V69Ajr1iXhluMpTB",
|
||||
"sync": false
|
||||
},
|
||||
{
|
||||
"__type__": "a1b5dhqiGxCkqZ/KM1XymD/",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 1
|
||||
},
|
||||
"_enabled": true,
|
||||
"level": {
|
||||
"__id__": 6
|
||||
},
|
||||
"_data": null
|
||||
},
|
||||
{
|
||||
"__type__": "cc.PrefabInfo",
|
||||
"root": {
|
||||
"__id__": 1
|
||||
},
|
||||
"asset": {
|
||||
"__uuid__": "10c60cf0-420d-41d3-b409-ae1ebad07af7"
|
||||
},
|
||||
"fileId": "02k6MWmIJPUJTWzoIGXfxy",
|
||||
"sync": false
|
||||
}
|
||||
]
|
||||
6
ListViewV2Demo/assets/Prefab/ListviewItem.prefab.meta
Normal file
6
ListViewV2Demo/assets/Prefab/ListviewItem.prefab.meta
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"ver": "1.0.0",
|
||||
"uuid": "10c60cf0-420d-41d3-b409-ae1ebad07af7",
|
||||
"asyncLoadAssets": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
6
ListViewV2Demo/assets/Scene.meta
Normal file
6
ListViewV2Demo/assets/Scene.meta
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"ver": "1.0.1",
|
||||
"uuid": "29f52784-2fca-467b-92e7-8fd9ef8c57b7",
|
||||
"isGroup": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
481
ListViewV2Demo/assets/Scene/helloworldJs.fire
Normal file
481
ListViewV2Demo/assets/Scene/helloworldJs.fire
Normal file
@@ -0,0 +1,481 @@
|
||||
[
|
||||
{
|
||||
"__type__": "cc.SceneAsset",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"_rawFiles": null,
|
||||
"scene": {
|
||||
"__id__": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Scene",
|
||||
"_objFlags": 0,
|
||||
"_parent": null,
|
||||
"_children": [
|
||||
{
|
||||
"__id__": 2
|
||||
}
|
||||
],
|
||||
"_tag": -1,
|
||||
"_active": true,
|
||||
"_components": [],
|
||||
"_prefab": null,
|
||||
"_id": "2d2f792f-a40c-49bb-a189-ed176a246e49",
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 255,
|
||||
"g": 255,
|
||||
"b": 255,
|
||||
"a": 255
|
||||
},
|
||||
"_cascadeOpacityEnabled": true,
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 0,
|
||||
"height": 0
|
||||
},
|
||||
"_localZOrder": 0,
|
||||
"_globalZOrder": 0,
|
||||
"_opacityModifyRGB": false,
|
||||
"groupIndex": 0,
|
||||
"autoReleaseAssets": false
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "Canvas",
|
||||
"_objFlags": 0,
|
||||
"_parent": {
|
||||
"__id__": 1
|
||||
},
|
||||
"_children": [
|
||||
{
|
||||
"__id__": 3
|
||||
},
|
||||
{
|
||||
"__id__": 6
|
||||
}
|
||||
],
|
||||
"_tag": -1,
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 13
|
||||
}
|
||||
],
|
||||
"_prefab": null,
|
||||
"_id": "a286bbGknJLZpRpxROV6M94",
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 252,
|
||||
"g": 252,
|
||||
"b": 252,
|
||||
"a": 255
|
||||
},
|
||||
"_cascadeOpacityEnabled": true,
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0.5,
|
||||
"y": 0.5
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 960,
|
||||
"height": 640
|
||||
},
|
||||
"_rotationX": 0,
|
||||
"_rotationY": 0,
|
||||
"_scaleX": 1,
|
||||
"_scaleY": 1,
|
||||
"_position": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 480,
|
||||
"y": 320
|
||||
},
|
||||
"_skewX": 0,
|
||||
"_skewY": 0,
|
||||
"_localZOrder": 0,
|
||||
"_globalZOrder": 0,
|
||||
"_opacityModifyRGB": false,
|
||||
"groupIndex": 0
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "background",
|
||||
"_objFlags": 0,
|
||||
"_parent": {
|
||||
"__id__": 2
|
||||
},
|
||||
"_children": [],
|
||||
"_tag": -1,
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 4
|
||||
},
|
||||
{
|
||||
"__id__": 5
|
||||
}
|
||||
],
|
||||
"_prefab": null,
|
||||
"_id": "e2e0crkOLxGrpMxpbC4iQg1",
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 27,
|
||||
"g": 38,
|
||||
"b": 46,
|
||||
"a": 255
|
||||
},
|
||||
"_cascadeOpacityEnabled": true,
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0.5,
|
||||
"y": 0.5
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 960,
|
||||
"height": 640
|
||||
},
|
||||
"_rotationX": 0,
|
||||
"_rotationY": 0,
|
||||
"_scaleX": 1,
|
||||
"_scaleY": 1,
|
||||
"_position": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"_skewX": 0,
|
||||
"_skewY": 0,
|
||||
"_localZOrder": 0,
|
||||
"_globalZOrder": 0,
|
||||
"_opacityModifyRGB": false,
|
||||
"groupIndex": 0
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Widget",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 3
|
||||
},
|
||||
"_enabled": true,
|
||||
"isAlignOnce": true,
|
||||
"_target": null,
|
||||
"_alignFlags": 45,
|
||||
"_left": 0,
|
||||
"_right": 0,
|
||||
"_top": 0,
|
||||
"_bottom": 0,
|
||||
"_verticalCenter": 0,
|
||||
"_horizontalCenter": 0,
|
||||
"_isAbsLeft": true,
|
||||
"_isAbsRight": true,
|
||||
"_isAbsTop": true,
|
||||
"_isAbsBottom": true,
|
||||
"_isAbsHorizontalCenter": true,
|
||||
"_isAbsVerticalCenter": true,
|
||||
"_originalWidth": 200,
|
||||
"_originalHeight": 150
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Sprite",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 3
|
||||
},
|
||||
"_enabled": true,
|
||||
"_spriteFrame": {
|
||||
"__uuid__": "410fb916-8721-4663-bab8-34397391ace7"
|
||||
},
|
||||
"_type": 1,
|
||||
"_sizeMode": 0,
|
||||
"_fillType": 0,
|
||||
"_fillCenter": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"_fillStart": 0,
|
||||
"_fillRange": 0,
|
||||
"_isTrimmedMode": true,
|
||||
"_srcBlendFactor": 770,
|
||||
"_dstBlendFactor": 771,
|
||||
"_atlas": null
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "ScrollView",
|
||||
"_objFlags": 0,
|
||||
"_parent": {
|
||||
"__id__": 2
|
||||
},
|
||||
"_children": [
|
||||
{
|
||||
"__id__": 7
|
||||
}
|
||||
],
|
||||
"_tag": -1,
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 10
|
||||
},
|
||||
{
|
||||
"__id__": 11
|
||||
},
|
||||
{
|
||||
"__id__": 12
|
||||
}
|
||||
],
|
||||
"_prefab": null,
|
||||
"_id": "92lL5sUpRLp4ACxwVgYY3A",
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 184,
|
||||
"g": 184,
|
||||
"b": 184,
|
||||
"a": 255
|
||||
},
|
||||
"_cascadeOpacityEnabled": true,
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0.5,
|
||||
"y": 0.5
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 400,
|
||||
"height": 600
|
||||
},
|
||||
"_rotationX": 0,
|
||||
"_rotationY": 0,
|
||||
"_scaleX": 1,
|
||||
"_scaleY": 1,
|
||||
"_position": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"_skewX": 0,
|
||||
"_skewY": 0,
|
||||
"_localZOrder": 0,
|
||||
"_globalZOrder": 0,
|
||||
"_opacityModifyRGB": false,
|
||||
"groupIndex": 0
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "view",
|
||||
"_objFlags": 0,
|
||||
"_parent": {
|
||||
"__id__": 6
|
||||
},
|
||||
"_children": [
|
||||
{
|
||||
"__id__": 8
|
||||
}
|
||||
],
|
||||
"_tag": -1,
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 9
|
||||
}
|
||||
],
|
||||
"_prefab": null,
|
||||
"_id": "05kf/Rkl1BiLiCJB9Ad22Z",
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 255,
|
||||
"g": 255,
|
||||
"b": 255,
|
||||
"a": 255
|
||||
},
|
||||
"_cascadeOpacityEnabled": true,
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0.5,
|
||||
"y": 1
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 400,
|
||||
"height": 600
|
||||
},
|
||||
"_rotationX": 0,
|
||||
"_rotationY": 0,
|
||||
"_scaleX": 1,
|
||||
"_scaleY": 1,
|
||||
"_position": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0,
|
||||
"y": 300
|
||||
},
|
||||
"_skewX": 0,
|
||||
"_skewY": 0,
|
||||
"_localZOrder": 0,
|
||||
"_globalZOrder": 0,
|
||||
"_opacityModifyRGB": false,
|
||||
"groupIndex": 0
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "content",
|
||||
"_objFlags": 0,
|
||||
"_parent": {
|
||||
"__id__": 7
|
||||
},
|
||||
"_children": [],
|
||||
"_tag": -1,
|
||||
"_active": true,
|
||||
"_components": [],
|
||||
"_prefab": null,
|
||||
"_id": "79OIFfXElLr4eQ/hGJLNpN",
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 255,
|
||||
"g": 255,
|
||||
"b": 255,
|
||||
"a": 255
|
||||
},
|
||||
"_cascadeOpacityEnabled": true,
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0,
|
||||
"y": 1
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 400,
|
||||
"height": 600
|
||||
},
|
||||
"_rotationX": 0,
|
||||
"_rotationY": 0,
|
||||
"_scaleX": 1,
|
||||
"_scaleY": 1,
|
||||
"_position": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": -200,
|
||||
"y": 0
|
||||
},
|
||||
"_skewX": 0,
|
||||
"_skewY": 0,
|
||||
"_localZOrder": 0,
|
||||
"_globalZOrder": 0,
|
||||
"_opacityModifyRGB": false,
|
||||
"groupIndex": 0
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Mask",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 7
|
||||
},
|
||||
"_enabled": true,
|
||||
"_type": 0,
|
||||
"_segements": 64,
|
||||
"_N$spriteFrame": null,
|
||||
"_N$alphaThreshold": 1,
|
||||
"_N$inverted": false
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Sprite",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 6
|
||||
},
|
||||
"_enabled": true,
|
||||
"_spriteFrame": {
|
||||
"__uuid__": "9bbda31e-ad49-43c9-aaf2-f7d9896bac69"
|
||||
},
|
||||
"_type": 1,
|
||||
"_sizeMode": 0,
|
||||
"_fillType": 0,
|
||||
"_fillCenter": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"_fillStart": 0,
|
||||
"_fillRange": 0,
|
||||
"_isTrimmedMode": true,
|
||||
"_srcBlendFactor": 770,
|
||||
"_dstBlendFactor": 771,
|
||||
"_atlas": null
|
||||
},
|
||||
{
|
||||
"__type__": "cc.ScrollView",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 6
|
||||
},
|
||||
"_enabled": true,
|
||||
"content": {
|
||||
"__id__": 8
|
||||
},
|
||||
"horizontal": false,
|
||||
"vertical": true,
|
||||
"inertia": true,
|
||||
"brake": 0.75,
|
||||
"elastic": true,
|
||||
"bounceDuration": 0.23,
|
||||
"scrollEvents": [],
|
||||
"cancelInnerEvents": true,
|
||||
"_N$horizontalScrollBar": null,
|
||||
"_N$verticalScrollBar": null
|
||||
},
|
||||
{
|
||||
"__type__": "86872n9U6tCEobIPwudn2h/",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 6
|
||||
},
|
||||
"_enabled": true,
|
||||
"scrollview": {
|
||||
"__id__": 11
|
||||
},
|
||||
"prefab": {
|
||||
"__uuid__": "10c60cf0-420d-41d3-b409-ae1ebad07af7"
|
||||
},
|
||||
"content": {
|
||||
"__id__": 8
|
||||
},
|
||||
"mask": {
|
||||
"__id__": 9
|
||||
}
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Canvas",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 2
|
||||
},
|
||||
"_enabled": true,
|
||||
"_designResolution": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 960,
|
||||
"height": 640
|
||||
},
|
||||
"_fitWidth": false,
|
||||
"_fitHeight": true
|
||||
}
|
||||
]
|
||||
7
ListViewV2Demo/assets/Scene/helloworldJs.fire.meta
Normal file
7
ListViewV2Demo/assets/Scene/helloworldJs.fire.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"ver": "0.9.0",
|
||||
"uuid": "2d2f792f-a40c-49bb-a189-ed176a246e49",
|
||||
"asyncLoadAssets": false,
|
||||
"autoReleaseAssets": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
481
ListViewV2Demo/assets/Scene/helloworldTs.fire
Normal file
481
ListViewV2Demo/assets/Scene/helloworldTs.fire
Normal file
@@ -0,0 +1,481 @@
|
||||
[
|
||||
{
|
||||
"__type__": "cc.SceneAsset",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"_rawFiles": null,
|
||||
"scene": {
|
||||
"__id__": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Scene",
|
||||
"_objFlags": 0,
|
||||
"_parent": null,
|
||||
"_children": [
|
||||
{
|
||||
"__id__": 2
|
||||
}
|
||||
],
|
||||
"_tag": -1,
|
||||
"_active": true,
|
||||
"_components": [],
|
||||
"_prefab": null,
|
||||
"_id": "3955e774-48e8-4785-9050-195165faa0ce",
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 255,
|
||||
"g": 255,
|
||||
"b": 255,
|
||||
"a": 255
|
||||
},
|
||||
"_cascadeOpacityEnabled": true,
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 0,
|
||||
"height": 0
|
||||
},
|
||||
"_localZOrder": 0,
|
||||
"_globalZOrder": 0,
|
||||
"_opacityModifyRGB": false,
|
||||
"groupIndex": 0,
|
||||
"autoReleaseAssets": false
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "Canvas",
|
||||
"_objFlags": 0,
|
||||
"_parent": {
|
||||
"__id__": 1
|
||||
},
|
||||
"_children": [
|
||||
{
|
||||
"__id__": 3
|
||||
},
|
||||
{
|
||||
"__id__": 6
|
||||
}
|
||||
],
|
||||
"_tag": -1,
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 13
|
||||
}
|
||||
],
|
||||
"_prefab": null,
|
||||
"_id": "a286bbGknJLZpRpxROV6M94",
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 252,
|
||||
"g": 252,
|
||||
"b": 252,
|
||||
"a": 255
|
||||
},
|
||||
"_cascadeOpacityEnabled": true,
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0.5,
|
||||
"y": 0.5
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 960,
|
||||
"height": 640
|
||||
},
|
||||
"_rotationX": 0,
|
||||
"_rotationY": 0,
|
||||
"_scaleX": 1,
|
||||
"_scaleY": 1,
|
||||
"_position": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 480,
|
||||
"y": 320
|
||||
},
|
||||
"_skewX": 0,
|
||||
"_skewY": 0,
|
||||
"_localZOrder": 0,
|
||||
"_globalZOrder": 0,
|
||||
"_opacityModifyRGB": false,
|
||||
"groupIndex": 0
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "background",
|
||||
"_objFlags": 0,
|
||||
"_parent": {
|
||||
"__id__": 2
|
||||
},
|
||||
"_children": [],
|
||||
"_tag": -1,
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 4
|
||||
},
|
||||
{
|
||||
"__id__": 5
|
||||
}
|
||||
],
|
||||
"_prefab": null,
|
||||
"_id": "e2e0crkOLxGrpMxpbC4iQg1",
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 27,
|
||||
"g": 38,
|
||||
"b": 46,
|
||||
"a": 255
|
||||
},
|
||||
"_cascadeOpacityEnabled": true,
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0.5,
|
||||
"y": 0.5
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 960,
|
||||
"height": 640
|
||||
},
|
||||
"_rotationX": 0,
|
||||
"_rotationY": 0,
|
||||
"_scaleX": 1,
|
||||
"_scaleY": 1,
|
||||
"_position": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"_skewX": 0,
|
||||
"_skewY": 0,
|
||||
"_localZOrder": 0,
|
||||
"_globalZOrder": 0,
|
||||
"_opacityModifyRGB": false,
|
||||
"groupIndex": 0
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Widget",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 3
|
||||
},
|
||||
"_enabled": true,
|
||||
"isAlignOnce": true,
|
||||
"_target": null,
|
||||
"_alignFlags": 45,
|
||||
"_left": 0,
|
||||
"_right": 0,
|
||||
"_top": 0,
|
||||
"_bottom": 0,
|
||||
"_verticalCenter": 0,
|
||||
"_horizontalCenter": 0,
|
||||
"_isAbsLeft": true,
|
||||
"_isAbsRight": true,
|
||||
"_isAbsTop": true,
|
||||
"_isAbsBottom": true,
|
||||
"_isAbsHorizontalCenter": true,
|
||||
"_isAbsVerticalCenter": true,
|
||||
"_originalWidth": 200,
|
||||
"_originalHeight": 150
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Sprite",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 3
|
||||
},
|
||||
"_enabled": true,
|
||||
"_spriteFrame": {
|
||||
"__uuid__": "410fb916-8721-4663-bab8-34397391ace7"
|
||||
},
|
||||
"_type": 1,
|
||||
"_sizeMode": 0,
|
||||
"_fillType": 0,
|
||||
"_fillCenter": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"_fillStart": 0,
|
||||
"_fillRange": 0,
|
||||
"_isTrimmedMode": true,
|
||||
"_srcBlendFactor": 770,
|
||||
"_dstBlendFactor": 771,
|
||||
"_atlas": null
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "ScrollView",
|
||||
"_objFlags": 0,
|
||||
"_parent": {
|
||||
"__id__": 2
|
||||
},
|
||||
"_children": [
|
||||
{
|
||||
"__id__": 7
|
||||
}
|
||||
],
|
||||
"_tag": -1,
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 10
|
||||
},
|
||||
{
|
||||
"__id__": 11
|
||||
},
|
||||
{
|
||||
"__id__": 12
|
||||
}
|
||||
],
|
||||
"_prefab": null,
|
||||
"_id": "92lL5sUpRLp4ACxwVgYY3A",
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 184,
|
||||
"g": 184,
|
||||
"b": 184,
|
||||
"a": 255
|
||||
},
|
||||
"_cascadeOpacityEnabled": true,
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0.5,
|
||||
"y": 0.5
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 400,
|
||||
"height": 600
|
||||
},
|
||||
"_rotationX": 0,
|
||||
"_rotationY": 0,
|
||||
"_scaleX": 1,
|
||||
"_scaleY": 1,
|
||||
"_position": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"_skewX": 0,
|
||||
"_skewY": 0,
|
||||
"_localZOrder": 0,
|
||||
"_globalZOrder": 0,
|
||||
"_opacityModifyRGB": false,
|
||||
"groupIndex": 0
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "view",
|
||||
"_objFlags": 0,
|
||||
"_parent": {
|
||||
"__id__": 6
|
||||
},
|
||||
"_children": [
|
||||
{
|
||||
"__id__": 8
|
||||
}
|
||||
],
|
||||
"_tag": -1,
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 9
|
||||
}
|
||||
],
|
||||
"_prefab": null,
|
||||
"_id": "05kf/Rkl1BiLiCJB9Ad22Z",
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 255,
|
||||
"g": 255,
|
||||
"b": 255,
|
||||
"a": 255
|
||||
},
|
||||
"_cascadeOpacityEnabled": true,
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0.5,
|
||||
"y": 1
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 400,
|
||||
"height": 600
|
||||
},
|
||||
"_rotationX": 0,
|
||||
"_rotationY": 0,
|
||||
"_scaleX": 1,
|
||||
"_scaleY": 1,
|
||||
"_position": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0,
|
||||
"y": 300
|
||||
},
|
||||
"_skewX": 0,
|
||||
"_skewY": 0,
|
||||
"_localZOrder": 0,
|
||||
"_globalZOrder": 0,
|
||||
"_opacityModifyRGB": false,
|
||||
"groupIndex": 0
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "content",
|
||||
"_objFlags": 0,
|
||||
"_parent": {
|
||||
"__id__": 7
|
||||
},
|
||||
"_children": [],
|
||||
"_tag": -1,
|
||||
"_active": true,
|
||||
"_components": [],
|
||||
"_prefab": null,
|
||||
"_id": "79OIFfXElLr4eQ/hGJLNpN",
|
||||
"_opacity": 255,
|
||||
"_color": {
|
||||
"__type__": "cc.Color",
|
||||
"r": 255,
|
||||
"g": 255,
|
||||
"b": 255,
|
||||
"a": 255
|
||||
},
|
||||
"_cascadeOpacityEnabled": true,
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0,
|
||||
"y": 1
|
||||
},
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 400,
|
||||
"height": 600
|
||||
},
|
||||
"_rotationX": 0,
|
||||
"_rotationY": 0,
|
||||
"_scaleX": 1,
|
||||
"_scaleY": 1,
|
||||
"_position": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": -200,
|
||||
"y": 0
|
||||
},
|
||||
"_skewX": 0,
|
||||
"_skewY": 0,
|
||||
"_localZOrder": 0,
|
||||
"_globalZOrder": 0,
|
||||
"_opacityModifyRGB": false,
|
||||
"groupIndex": 0
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Mask",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 7
|
||||
},
|
||||
"_enabled": true,
|
||||
"_type": 0,
|
||||
"_segements": 64,
|
||||
"_N$spriteFrame": null,
|
||||
"_N$alphaThreshold": 1,
|
||||
"_N$inverted": false
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Sprite",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 6
|
||||
},
|
||||
"_enabled": true,
|
||||
"_spriteFrame": {
|
||||
"__uuid__": "9bbda31e-ad49-43c9-aaf2-f7d9896bac69"
|
||||
},
|
||||
"_type": 1,
|
||||
"_sizeMode": 0,
|
||||
"_fillType": 0,
|
||||
"_fillCenter": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0,
|
||||
"y": 0
|
||||
},
|
||||
"_fillStart": 0,
|
||||
"_fillRange": 0,
|
||||
"_isTrimmedMode": true,
|
||||
"_srcBlendFactor": 770,
|
||||
"_dstBlendFactor": 771,
|
||||
"_atlas": null
|
||||
},
|
||||
{
|
||||
"__type__": "cc.ScrollView",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 6
|
||||
},
|
||||
"_enabled": true,
|
||||
"content": {
|
||||
"__id__": 8
|
||||
},
|
||||
"horizontal": false,
|
||||
"vertical": true,
|
||||
"inertia": true,
|
||||
"brake": 0.75,
|
||||
"elastic": true,
|
||||
"bounceDuration": 0.23,
|
||||
"scrollEvents": [],
|
||||
"cancelInnerEvents": true,
|
||||
"_N$horizontalScrollBar": null,
|
||||
"_N$verticalScrollBar": null
|
||||
},
|
||||
{
|
||||
"__type__": "93ce6/0kVBB4b8cNGqV0EYe",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 6
|
||||
},
|
||||
"_enabled": true,
|
||||
"scrollview": {
|
||||
"__id__": 11
|
||||
},
|
||||
"prefab": {
|
||||
"__uuid__": "10c60cf0-420d-41d3-b409-ae1ebad07af7"
|
||||
},
|
||||
"content": {
|
||||
"__id__": 8
|
||||
},
|
||||
"mask": {
|
||||
"__id__": 9
|
||||
}
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Canvas",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 2
|
||||
},
|
||||
"_enabled": true,
|
||||
"_designResolution": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 960,
|
||||
"height": 640
|
||||
},
|
||||
"_fitWidth": false,
|
||||
"_fitHeight": true
|
||||
}
|
||||
]
|
||||
7
ListViewV2Demo/assets/Scene/helloworldTs.fire.meta
Normal file
7
ListViewV2Demo/assets/Scene/helloworldTs.fire.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"ver": "0.9.0",
|
||||
"uuid": "3955e774-48e8-4785-9050-195165faa0ce",
|
||||
"asyncLoadAssets": false,
|
||||
"autoReleaseAssets": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
6
ListViewV2Demo/assets/Script.meta
Normal file
6
ListViewV2Demo/assets/Script.meta
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"ver": "1.0.1",
|
||||
"uuid": "4734c20c-0db8-4eb2-92ea-e692f4d70934",
|
||||
"isGroup": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
22
ListViewV2Demo/assets/Script/HelloWorld.js
Normal file
22
ListViewV2Demo/assets/Script/HelloWorld.js
Normal file
@@ -0,0 +1,22 @@
|
||||
cc.Class({
|
||||
extends: cc.Component,
|
||||
|
||||
properties: {
|
||||
label: {
|
||||
default: null,
|
||||
type: cc.Label
|
||||
},
|
||||
// defaults, set visually when attaching this script to the Canvas
|
||||
text: 'Hello, World!'
|
||||
},
|
||||
|
||||
// use this for initialization
|
||||
onLoad: function () {
|
||||
this.label.string = this.text;
|
||||
},
|
||||
|
||||
// called every frame
|
||||
update: function (dt) {
|
||||
|
||||
},
|
||||
});
|
||||
9
ListViewV2Demo/assets/Script/HelloWorld.js.meta
Normal file
9
ListViewV2Demo/assets/Script/HelloWorld.js.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.0.5",
|
||||
"uuid": "280c3aec-6492-4a9d-9f51-a9b00b570b4a",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
5
ListViewV2Demo/assets/Script/Listview-js.meta
Normal file
5
ListViewV2Demo/assets/Script/Listview-js.meta
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"ver": "1.0.1",
|
||||
"uuid": "e15db58e-2ca5-416a-be41-75b225cc342d",
|
||||
"subMetas": {}
|
||||
}
|
||||
46
ListViewV2Demo/assets/Script/Listview-js/layout_utils.js
Normal file
46
ListViewV2Demo/assets/Script/Listview-js/layout_utils.js
Normal file
@@ -0,0 +1,46 @@
|
||||
var LayoutUtil = /** @class */ (function () {
|
||||
function LayoutUtil() {
|
||||
}
|
||||
LayoutUtil.vertical_layout = function (index, item_width, item_height, column, gap_x, gap_y, padding_left, padding_top) {
|
||||
if (column === void 0) { column = 1; }
|
||||
if (gap_x === void 0) { gap_x = 0; }
|
||||
if (gap_y === void 0) { gap_y = 0; }
|
||||
if (padding_left === void 0) { padding_left = 0; }
|
||||
if (padding_top === void 0) { padding_top = 0; }
|
||||
var x = (index % column) * (item_width + gap_x) + padding_left;
|
||||
var y = -Math.floor(index / column) * (item_height + gap_y) - padding_top;
|
||||
return [x, y];
|
||||
};
|
||||
LayoutUtil.horizontal_layout = function (index, item_width, item_height, row, gap_x, gap_y, padding_left, padding_top) {
|
||||
if (row === void 0) { row = 1; }
|
||||
if (gap_x === void 0) { gap_x = 0; }
|
||||
if (gap_y === void 0) { gap_y = 0; }
|
||||
if (padding_left === void 0) { padding_left = 0; }
|
||||
if (padding_top === void 0) { padding_top = 0; }
|
||||
var x = Math.floor(index / row) * (item_width + gap_x) + padding_left;
|
||||
var y = -(index % row) * (item_height + gap_y) - padding_top;
|
||||
return [x, y];
|
||||
};
|
||||
LayoutUtil.set_pivot_smart = function (node, ax, ay, recursive) {
|
||||
if (recursive === void 0) { recursive = false; }
|
||||
var deltaAx = ax - node.anchorX;
|
||||
var deltaAy = ay - node.anchorY;
|
||||
node.anchorX = ax;
|
||||
node.anchorY = ay;
|
||||
//改变节点锚点,位置值相对锚点不变。需要调整节点至新位置才能保持一致视觉效果
|
||||
var deltaX = deltaAx * node.width;
|
||||
var deltaY = deltaAy * node.height;
|
||||
node.x += deltaX;
|
||||
node.y += deltaY;
|
||||
node.children.forEach(function (child) {
|
||||
//父节点锚点改变,子节点相对父节点位置值不变,需要调整子节点至新位置才能保持一致视觉效果
|
||||
child.x -= deltaX;
|
||||
child.y -= deltaY;
|
||||
if (recursive) {
|
||||
LayoutUtil.set_pivot_smart(child, ax, ay);
|
||||
}
|
||||
});
|
||||
};
|
||||
return LayoutUtil;
|
||||
}());
|
||||
exports.LayoutUtil = LayoutUtil;
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.0.5",
|
||||
"uuid": "ded623b9-8cae-4b6b-b1cf-82747026c50e",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
763
ListViewV2Demo/assets/Script/Listview-js/listview.js
Normal file
763
ListViewV2Demo/assets/Script/Listview-js/listview.js
Normal file
@@ -0,0 +1,763 @@
|
||||
var layout_utils_1 = require("layout_utils");
|
||||
var ListView = /** @class */ (function () {
|
||||
function ListView(params) {
|
||||
this._selected_index = -1;
|
||||
this.scrollview = params.scrollview;
|
||||
this.mask = params.mask;
|
||||
this.content = params.content;
|
||||
this.item_tpl = params.item_tpl;
|
||||
this.item_tpl.active = false;
|
||||
this.item_width = this.item_tpl.width;
|
||||
this.item_height = this.item_tpl.height;
|
||||
this.dir = params.direction || ListViewDir.Vertical;
|
||||
this.width = params.width || this.scrollview.node.width;
|
||||
this.height = params.height || this.scrollview.node.height;
|
||||
this.gap_x = params.gap_x || 0;
|
||||
this.gap_y = params.gap_y || 0;
|
||||
this.padding_left = params.padding_left || 0;
|
||||
this.padding_right = params.padding_right || 0;
|
||||
this.padding_top = params.padding_top || 0;
|
||||
this.padding_bottom = params.padding_bottom || 0;
|
||||
this.item_anchorX = params.item_anchorX != null ? params.item_anchorX : 0;
|
||||
this.item_anchorY = params.item_anchorY != null ? params.item_anchorY : 1;
|
||||
this.row = params.row || 1;
|
||||
this.col = params.column || 1;
|
||||
this.cb_host = params.cb_host;
|
||||
this.scroll_to_end_cb = params.scroll_to_end_cb;
|
||||
this.item_class = params.item_class;
|
||||
this.auto_scrolling = params.auto_scrolling || false;
|
||||
this.item_pool = [];
|
||||
if (this.dir == ListViewDir.Vertical) {
|
||||
var content_width = (this.item_width + this.gap_x) * this.col - this.gap_x + this.padding_left + this.padding_right;
|
||||
if (content_width > this.width) {
|
||||
cc.log("content_width > width, resize listview to content_width,", this.width, "->", content_width);
|
||||
this.width = content_width;
|
||||
}
|
||||
this.set_content_size(this.width, 0);
|
||||
}
|
||||
else {
|
||||
var content_height = (this.item_height + this.gap_y) * this.row - this.gap_y + this.padding_top + this.padding_bottom;
|
||||
if (content_height > this.height) {
|
||||
cc.log("content_height > height, resize listview to content_height,", this.height, "->", content_height);
|
||||
this.height = content_height;
|
||||
}
|
||||
this.set_content_size(0, this.height);
|
||||
}
|
||||
this.original_width = this.width;
|
||||
this.original_height = this.height;
|
||||
this.mask.node.setContentSize(this.width, this.height);
|
||||
this.scrollview.node.setContentSize(this.width, this.height);
|
||||
this.scrollview.vertical = this.dir == ListViewDir.Vertical;
|
||||
this.scrollview.horizontal = this.dir == ListViewDir.Horizontal;
|
||||
this.scrollview.inertia = true;
|
||||
this.scrollview.node.on("scrolling", this.on_scrolling, this);
|
||||
this.scrollview.node.on("scroll-to-bottom", this.on_scroll_to_end, this);
|
||||
this.scrollview.node.on("scroll-to-right", this.on_scroll_to_end, this);
|
||||
this.scrollview.node.on(cc.Node.EventType.TOUCH_START, this.on_scroll_touch_start, this);
|
||||
this.scrollview.node.on(cc.Node.EventType.TOUCH_END, this.on_scroll_touch_end, this);
|
||||
this.scrollview.node.on(cc.Node.EventType.TOUCH_CANCEL, this.on_scroll_touch_cancel, this);
|
||||
}
|
||||
ListView.prototype.on_scroll_touch_start = function (event) {
|
||||
this._touchBeganPosition = cc.v2(event.touch.getLocation().x, event.touch.getLocation().y);
|
||||
};
|
||||
ListView.prototype.on_scroll_touch_cancel = function (event) {
|
||||
this._touchEndPosition = event.touch.getLocation();
|
||||
this.handle_release_logic();
|
||||
};
|
||||
ListView.prototype.on_scroll_touch_end = function (event) {
|
||||
this._touchEndPosition = event.touch.getLocation();
|
||||
this.handle_release_logic();
|
||||
};
|
||||
ListView.prototype.handle_release_logic = function () {
|
||||
var touchPos = this._touchEndPosition;
|
||||
var moveOffset = this._touchBeganPosition.sub(this._touchEndPosition);
|
||||
var dragDirection = this.get_drag_direction(moveOffset);
|
||||
if (dragDirection != 0) {
|
||||
return;
|
||||
}
|
||||
if (!this.packItems || !this.packItems.length) {
|
||||
return;
|
||||
}
|
||||
//无滑动的情况下点击
|
||||
var touchPosInContent = this.content.convertToNodeSpaceAR(touchPos);
|
||||
for (var i = this.start_index; i <= this.stop_index; i++) {
|
||||
var packItem = this.packItems[i];
|
||||
if (packItem && packItem.item && packItem.item.node.getBoundingBox().contains(touchPosInContent)) {
|
||||
packItem.item.onTouchEnd(packItem.item.node.convertToNodeSpaceAR(touchPos), packItem.data, i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
ListView.prototype.get_drag_direction = function (moveOffset) {
|
||||
if (this.dir === ListViewDir.Horizontal) {
|
||||
if (Math.abs(moveOffset.x) < 3) {
|
||||
return 0;
|
||||
}
|
||||
return (moveOffset.x > 0 ? 1 : -1);
|
||||
}
|
||||
else if (this.dir === ListViewDir.Vertical) {
|
||||
// 由于滚动 Y 轴的原点在在右上角所以应该是小于 0
|
||||
if (Math.abs(moveOffset.y) < 3) {
|
||||
return 0;
|
||||
}
|
||||
return (moveOffset.y < 0 ? 1 : -1);
|
||||
}
|
||||
};
|
||||
ListView.prototype.on_scroll_to_end = function () {
|
||||
if (this.scroll_to_end_cb) {
|
||||
this.scroll_to_end_cb.call(this.cb_host);
|
||||
}
|
||||
};
|
||||
ListView.prototype.on_scrolling = function () {
|
||||
var pos;
|
||||
var threshold;
|
||||
if (this.dir == ListViewDir.Vertical) {
|
||||
pos = this.content.y;
|
||||
threshold = this.item_height;
|
||||
}
|
||||
else {
|
||||
pos = this.content.x;
|
||||
threshold = this.item_width;
|
||||
}
|
||||
if (this.last_content_pos != null && Math.abs(pos - this.last_content_pos) < threshold) {
|
||||
return;
|
||||
}
|
||||
this.last_content_pos = pos;
|
||||
this.render();
|
||||
};
|
||||
ListView.prototype.render = function () {
|
||||
if (!this.packItems || !this.packItems.length) {
|
||||
return;
|
||||
}
|
||||
if (this.dir == ListViewDir.Vertical) {
|
||||
var posy = this.content.y;
|
||||
// cc.log("onscrolling, content posy=", posy);
|
||||
if (posy < 0) {
|
||||
posy = 0;
|
||||
}
|
||||
else if (posy > this.content_height - this.height) {
|
||||
posy = this.content_height - this.height;
|
||||
}
|
||||
var viewport_start = -posy;
|
||||
var viewport_stop = viewport_start - this.height;
|
||||
// while(this.packItems[start].y - this.item_height > viewport_start)
|
||||
// {
|
||||
// start++;
|
||||
// }
|
||||
// while(this.packItems[stop].y < viewport_stop)
|
||||
// {
|
||||
// stop--;
|
||||
// }
|
||||
var start = this.indexFromOffset(viewport_start);
|
||||
var stop = this.indexFromOffset(viewport_stop);
|
||||
//expand viewport for better experience
|
||||
start = Math.max(start - this.col, 0);
|
||||
stop = Math.min(this.packItems.length - 1, stop + this.col);
|
||||
if (start != this.start_index) {
|
||||
this.start_index = start;
|
||||
this.renderDirty = true;
|
||||
}
|
||||
if (stop != this.stop_index) {
|
||||
this.stop_index = stop;
|
||||
this.renderDirty = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
var posx = this.content.x;
|
||||
// cc.log("onscrolling, content posx=", posx);
|
||||
if (posx > 0) {
|
||||
posx = 0;
|
||||
}
|
||||
else if (posx < this.width - this.content_width) {
|
||||
posx = this.width - this.content_width;
|
||||
}
|
||||
var viewport_start = -posx;
|
||||
var viewport_stop = viewport_start + this.width;
|
||||
// while(this.packItems[start].x + this.item_width < viewport_start)
|
||||
// {
|
||||
// start++;
|
||||
// }
|
||||
// while(this.packItems[stop].x > viewport_stop)
|
||||
// {
|
||||
// stop--;
|
||||
// }
|
||||
var start = this.indexFromOffset(viewport_start);
|
||||
var stop = this.indexFromOffset(viewport_stop);
|
||||
//expand viewport for better experience
|
||||
start = Math.max(start - this.row, 0);
|
||||
stop = Math.min(this.packItems.length - 1, stop + this.row);
|
||||
if (start != this.start_index) {
|
||||
this.start_index = start;
|
||||
this.renderDirty = true;
|
||||
}
|
||||
if (stop != this.stop_index) {
|
||||
this.stop_index = stop;
|
||||
this.renderDirty = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
ListView.prototype.onUpdate = function () {
|
||||
if (this.renderDirty && cc.isValid(this.scrollview.node)) {
|
||||
// cc.log("listView, render_from:", this.start_index, this.stop_index);
|
||||
this.render_items();
|
||||
|
||||
this.renderDirty = false;
|
||||
}
|
||||
};
|
||||
//不支持多行多列
|
||||
ListView.prototype.indexFromOffset = function (offset) {
|
||||
var low = 0;
|
||||
var high = 0;
|
||||
var max_idx = 0;
|
||||
high = max_idx = this.packItems.length - 1;
|
||||
if (this.dir == ListViewDir.Vertical) {
|
||||
while (high >= low) {
|
||||
var index = low + Math.floor((high - low) / 2);
|
||||
var itemStart = this.packItems[index].y;
|
||||
var itemStop = index < max_idx ? this.packItems[index + 1].y : -this.content_height;
|
||||
if (offset <= itemStart && offset >= itemStop) {
|
||||
return index;
|
||||
}
|
||||
else if (offset > itemStart) {
|
||||
high = index - 1;
|
||||
}
|
||||
else {
|
||||
low = index + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
while (high >= low) {
|
||||
var index = low + Math.floor((high - low) / 2);
|
||||
var itemStart = this.packItems[index].x;
|
||||
var itemStop = index < max_idx ? this.packItems[index + 1].x : this.content_width;
|
||||
if (offset >= itemStart && offset <= itemStop) {
|
||||
return index;
|
||||
}
|
||||
else if (offset > itemStart) {
|
||||
low = index + 1;
|
||||
}
|
||||
else {
|
||||
high = index - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
};
|
||||
ListView.prototype.select_data = function (data) {
|
||||
var idx = this.packItems.findIndex(function (item) { return item.data == data; });
|
||||
if (idx != -1) {
|
||||
this.select_item(idx);
|
||||
}
|
||||
};
|
||||
ListView.prototype.select_item = function (index) {
|
||||
if (index == this._selected_index) {
|
||||
return;
|
||||
}
|
||||
if (this._selected_index != -1) {
|
||||
this.inner_select_item(this._selected_index, false);
|
||||
}
|
||||
this._selected_index = index;
|
||||
this.inner_select_item(index, true);
|
||||
};
|
||||
ListView.prototype.inner_select_item = function (index, is_select) {
|
||||
var packItem = this.packItems[index];
|
||||
if (!packItem) {
|
||||
cc.warn("inner_select_item index is out of range{", 0, this.packItems.length - 1, "}", index);
|
||||
return;
|
||||
}
|
||||
packItem.is_select = is_select;
|
||||
if (packItem.item) {
|
||||
packItem.item.onSetSelect(is_select, index);
|
||||
if (is_select) {
|
||||
packItem.item.onSelected(packItem.data, index);
|
||||
}
|
||||
}
|
||||
};
|
||||
ListView.prototype.spawn_item = function (index) {
|
||||
var item = this.item_pool.pop();
|
||||
if (!item) {
|
||||
item = cc.instantiate(this.item_tpl).getComponent(this.item_class);
|
||||
item.node.active = true;
|
||||
//仅仅改变父节点锚点,子元素位置不会随之变化
|
||||
// item.node.setAnchorPoint(this.item_anchorX, this.item_anchorY);
|
||||
layout_utils_1.LayoutUtil.set_pivot_smart(item.node, this.item_anchorX, this.item_anchorY);
|
||||
item.onInit();
|
||||
// cc.log("spawn_item", index);
|
||||
}
|
||||
item.node.parent = this.content;
|
||||
return item;
|
||||
};
|
||||
ListView.prototype.recycle_item = function (packItem) {
|
||||
var item = packItem.item;
|
||||
if (item && cc.isValid(item.node)) {
|
||||
item.onRecycle(packItem.data);
|
||||
item.node.removeFromParent();
|
||||
this.item_pool.push(item);
|
||||
packItem.item = null;
|
||||
}
|
||||
};
|
||||
ListView.prototype.clear_items = function () {
|
||||
var _this = this;
|
||||
if (this.packItems) {
|
||||
this.packItems.forEach(function (packItem) {
|
||||
_this.recycle_item(packItem);
|
||||
});
|
||||
}
|
||||
};
|
||||
ListView.prototype.render_items = function () {
|
||||
var packItem;
|
||||
for (var i = 0; i < this.start_index; i++) {
|
||||
packItem = this.packItems[i];
|
||||
if (packItem.item) {
|
||||
// cc.log("recycle_item", i);
|
||||
this.recycle_item(packItem);
|
||||
}
|
||||
}
|
||||
for (var i = this.packItems.length - 1; i > this.stop_index; i--) {
|
||||
packItem = this.packItems[i];
|
||||
if (packItem.item) {
|
||||
// cc.log("recycle_item", i);
|
||||
this.recycle_item(packItem);
|
||||
}
|
||||
}
|
||||
for (var i = this.start_index; i <= this.stop_index; i++) {
|
||||
packItem = this.packItems[i];
|
||||
if (!packItem.item) {
|
||||
// cc.log("render_item", i);
|
||||
packItem.item = this.spawn_item(i);
|
||||
packItem.item.onSetData(packItem.data, i);
|
||||
packItem.item.onSetSelect(packItem.is_select, i);
|
||||
if (packItem.is_select) {
|
||||
packItem.item.onSelected(packItem.data, i);
|
||||
}
|
||||
}
|
||||
//列表添加与删除时item位置会变化,因此每次render_items都要执行
|
||||
// packItem.item.node.setPosition(packItem.x, packItem.y);
|
||||
packItem.item.setLeftTop(packItem.x, packItem.y);
|
||||
}
|
||||
};
|
||||
ListView.prototype.pack_item = function (data) {
|
||||
return { x: 0, y: 0, data: data, item: null, is_select: false };
|
||||
};
|
||||
ListView.prototype.layout_items = function (start) {
|
||||
// cc.log("layout_items, start=", start);
|
||||
for (var index = start, stop = this.packItems.length; index < stop; index++) {
|
||||
var packItem = this.packItems[index];
|
||||
if (this.dir == ListViewDir.Vertical) {
|
||||
_a = layout_utils_1.LayoutUtil.vertical_layout(index, this.item_width, this.item_height, this.col, this.gap_x, this.gap_y, this.padding_left, this.padding_top), packItem.x = _a[0], packItem.y = _a[1];
|
||||
}
|
||||
else {
|
||||
_b = layout_utils_1.LayoutUtil.horizontal_layout(index, this.item_width, this.item_height, this.row, this.gap_x, this.gap_y, this.padding_left, this.padding_top), packItem.x = _b[0], packItem.y = _b[1];
|
||||
}
|
||||
}
|
||||
var _a, _b;
|
||||
};
|
||||
ListView.prototype.adjust_content = function () {
|
||||
if (this.packItems.length <= 0) {
|
||||
this.set_content_size(0, 0);
|
||||
return;
|
||||
}
|
||||
var last_packItem = this.packItems[this.packItems.length - 1];
|
||||
if (this.dir == ListViewDir.Vertical) {
|
||||
var height = Math.max(this.height, this.item_height - last_packItem.y + this.padding_bottom);
|
||||
this.set_content_size(this.content_width, height);
|
||||
}
|
||||
else {
|
||||
var width = Math.max(this.width, last_packItem.x + this.item_width + this.padding_right);
|
||||
this.set_content_size(width, this.content_height);
|
||||
}
|
||||
};
|
||||
ListView.prototype.set_content_size = function (width, height) {
|
||||
if (this.content_width != width) {
|
||||
this.content_width = width;
|
||||
this.content.width = width;
|
||||
}
|
||||
if (this.content_height != height) {
|
||||
this.content_height = height;
|
||||
this.content.height = height;
|
||||
}
|
||||
// cc.log("ListView, set_content_size", width, height, this.content.width, this.content.height);
|
||||
};
|
||||
ListView.prototype.set_viewport = function (width, height) {
|
||||
if (width == null) {
|
||||
width = this.width;
|
||||
}
|
||||
else if (width > this.content_width) {
|
||||
width = this.content_width;
|
||||
}
|
||||
if (height == null) {
|
||||
height = this.height;
|
||||
}
|
||||
else if (height > this.content_height) {
|
||||
height = this.content_height;
|
||||
}
|
||||
//设置遮罩区域尺寸
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.mask.node.setContentSize(width, height);
|
||||
this.scrollview.node.setContentSize(width, height);
|
||||
this.render();
|
||||
};
|
||||
ListView.prototype.renderAll = function (value) {
|
||||
var width;
|
||||
var height;
|
||||
if (value) {
|
||||
width = this.content_width;
|
||||
height = this.content_height;
|
||||
}
|
||||
else {
|
||||
width = this.original_width;
|
||||
height = this.original_height;
|
||||
}
|
||||
this.set_viewport(width, height);
|
||||
};
|
||||
ListView.prototype.set_data = function (datas) {
|
||||
var _this = this;
|
||||
if (this.packItems) {
|
||||
this.clear_items();
|
||||
this.packItems.length = 0;
|
||||
}
|
||||
else {
|
||||
this.packItems = [];
|
||||
}
|
||||
datas.forEach(function (data) {
|
||||
var packItem = _this.pack_item(data);
|
||||
_this.packItems.push(packItem);
|
||||
});
|
||||
this.layout_items(0);
|
||||
this.adjust_content();
|
||||
this.start_index = -1;
|
||||
this.stop_index = -1;
|
||||
if (this.dir == ListViewDir.Vertical) {
|
||||
this.content.y = 0;
|
||||
}
|
||||
else {
|
||||
this.content.x = 0;
|
||||
}
|
||||
if (this.packItems.length > 0) {
|
||||
this.render();
|
||||
}
|
||||
};
|
||||
ListView.prototype.insert_data = function (index) {
|
||||
var _this = this;
|
||||
var datas = [];
|
||||
for (var _i = 1; _i < arguments.length; _i++) {
|
||||
datas[_i - 1] = arguments[_i];
|
||||
}
|
||||
if (datas.length == 0) {
|
||||
cc.log("nothing to insert");
|
||||
return;
|
||||
}
|
||||
if (!this.packItems) {
|
||||
this.packItems = [];
|
||||
}
|
||||
if (index < 0 || index > this.packItems.length) {
|
||||
cc.warn("insert_data, invalid index", index);
|
||||
return;
|
||||
}
|
||||
var is_append = index == this.packItems.length;
|
||||
var packItems = [];
|
||||
datas.forEach(function (data) {
|
||||
var packItem = _this.pack_item(data);
|
||||
packItems.push(packItem);
|
||||
});
|
||||
(_a = this.packItems).splice.apply(_a, [index, 0].concat(packItems));
|
||||
this.layout_items(index);
|
||||
this.adjust_content();
|
||||
this.start_index = -1;
|
||||
this.stop_index = -1;
|
||||
if (this.auto_scrolling && is_append) {
|
||||
this.scroll_to_end();
|
||||
}
|
||||
this.render();
|
||||
var _a;
|
||||
};
|
||||
ListView.prototype.remove_data = function (index, count) {
|
||||
var _this = this;
|
||||
if (count === void 0) { count = 1; }
|
||||
if (!this.packItems) {
|
||||
cc.log("call set_data before call this method");
|
||||
return;
|
||||
}
|
||||
if (index < 0 || index >= this.packItems.length) {
|
||||
cc.warn("remove_data, invalid index", index);
|
||||
return;
|
||||
}
|
||||
if (count < 1) {
|
||||
cc.log("nothing to remove");
|
||||
return;
|
||||
}
|
||||
var old_length = this.packItems.length;
|
||||
var del_items = this.packItems.splice(index, count);
|
||||
//回收node
|
||||
del_items.forEach(function (packItem) {
|
||||
_this.recycle_item(packItem);
|
||||
});
|
||||
//重新排序index后面的
|
||||
if (index + count < old_length) {
|
||||
this.layout_items(index);
|
||||
}
|
||||
this.adjust_content();
|
||||
if (this.packItems.length > 0) {
|
||||
this.start_index = -1;
|
||||
this.stop_index = -1;
|
||||
this.render();
|
||||
}
|
||||
};
|
||||
ListView.prototype.append_data = function () {
|
||||
var datas = [];
|
||||
for (var _i = 0; _i < arguments.length; _i++) {
|
||||
datas[_i] = arguments[_i];
|
||||
}
|
||||
if (!this.packItems) {
|
||||
this.packItems = [];
|
||||
}
|
||||
this.insert_data.apply(this, [this.packItems.length].concat(datas));
|
||||
};
|
||||
ListView.prototype.scroll_to = function (index, time) {
|
||||
if (time === void 0) { time = 0; }
|
||||
if (!this.packItems) {
|
||||
return;
|
||||
}
|
||||
var packItem = this.packItems[index];
|
||||
if (!packItem) {
|
||||
cc.log("scroll_to, index out of range");
|
||||
return;
|
||||
}
|
||||
if (this.dir == ListViewDir.Vertical) {
|
||||
var min_y = this.height - this.content_height;
|
||||
if (min_y >= 0) {
|
||||
cc.log("no need to scroll");
|
||||
return;
|
||||
}
|
||||
var y = packItem.y;
|
||||
if (y < min_y) {
|
||||
y = min_y;
|
||||
cc.log("content reach bottom");
|
||||
}
|
||||
var x = this.content.x;
|
||||
if (time == 0) {
|
||||
this.scrollview.setContentPosition(cc.v2(x, -y));
|
||||
}
|
||||
else {
|
||||
this.scrollview.scrollToOffset(cc.v2(x, -y), time);
|
||||
}
|
||||
this.render();
|
||||
}
|
||||
else {
|
||||
var max_x = this.content_width - this.width;
|
||||
if (max_x <= 0) {
|
||||
cc.log("no need to scroll");
|
||||
return;
|
||||
}
|
||||
var x = packItem.x;
|
||||
if (x > max_x) {
|
||||
x = max_x;
|
||||
cc.log("content reach right");
|
||||
}
|
||||
var y = this.content.y;
|
||||
if (time == 0) {
|
||||
this.scrollview.setContentPosition(cc.v2(-x, y));
|
||||
}
|
||||
else {
|
||||
this.scrollview.scrollToOffset(cc.v2(-x, y), time);
|
||||
}
|
||||
this.render();
|
||||
}
|
||||
};
|
||||
ListView.prototype.get_scroll_offset = function () {
|
||||
var offset = this.scrollview.getScrollOffset();
|
||||
if (this.dir == ListViewDir.Vertical) {
|
||||
return offset.y;
|
||||
}
|
||||
else {
|
||||
return offset.x;
|
||||
}
|
||||
};
|
||||
ListView.prototype.scroll_to_offset = function (value, time) {
|
||||
if (time === void 0) { time = 0; }
|
||||
if (this.dir == ListViewDir.Vertical) {
|
||||
var x = this.content.x;
|
||||
if (time == 0) {
|
||||
this.scrollview.setContentPosition(cc.v2(x, value));
|
||||
}
|
||||
else {
|
||||
this.scrollview.scrollToOffset(cc.v2(x, value), time);
|
||||
}
|
||||
this.render();
|
||||
}
|
||||
else {
|
||||
var y = this.content.y;
|
||||
if (time == 0) {
|
||||
this.scrollview.setContentPosition(cc.v2(value, y));
|
||||
}
|
||||
else {
|
||||
this.scrollview.scrollToOffset(cc.v2(value, y), time);
|
||||
}
|
||||
this.render();
|
||||
}
|
||||
};
|
||||
ListView.prototype.scroll_to_end = function () {
|
||||
if (this.dir == ListViewDir.Vertical) {
|
||||
this.scrollview.scrollToBottom();
|
||||
}
|
||||
else {
|
||||
this.scrollview.scrollToRight();
|
||||
}
|
||||
};
|
||||
ListView.prototype.refresh_item = function (index, data) {
|
||||
var packItem = this.get_pack_item(index);
|
||||
if (!packItem) {
|
||||
return;
|
||||
}
|
||||
var oldData = packItem.data;
|
||||
packItem.data = data;
|
||||
if (packItem.item) {
|
||||
packItem.item.onRecycle(oldData);
|
||||
packItem.item.onSetData(data, index);
|
||||
}
|
||||
};
|
||||
ListView.prototype.reload_item = function (index) {
|
||||
var packItem = this.get_pack_item(index);
|
||||
if (packItem && packItem.item) {
|
||||
packItem.item.onRecycle(packItem.data);
|
||||
packItem.item.onSetData(packItem.data, index);
|
||||
}
|
||||
};
|
||||
ListView.prototype.get_pack_item = function (index) {
|
||||
if (!this.packItems) {
|
||||
cc.log("call set_data before call this method");
|
||||
return null;
|
||||
}
|
||||
if (index < 0 || index >= this.packItems.length) {
|
||||
cc.warn("get_pack_item, invalid index", index);
|
||||
return null;
|
||||
}
|
||||
return this.packItems[index];
|
||||
};
|
||||
ListView.prototype.get_item = function (index) {
|
||||
var packItem = this.get_pack_item(index);
|
||||
return packItem ? packItem.item : null;
|
||||
};
|
||||
ListView.prototype.get_data = function (index) {
|
||||
var packItem = this.get_pack_item(index);
|
||||
return packItem ? packItem.data : null;
|
||||
};
|
||||
ListView.prototype.find_item = function (predicate) {
|
||||
if (!this.packItems || !this.packItems.length) {
|
||||
cc.log("call set_data before call this method");
|
||||
return null;
|
||||
}
|
||||
for (var i = this.start_index; i <= this.stop_index; i++) {
|
||||
var packItem = this.packItems[i];
|
||||
if (predicate(packItem.data)) {
|
||||
return packItem.item;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
ListView.prototype.find_index = function (predicate) {
|
||||
if (!this.packItems || !this.packItems.length) {
|
||||
cc.log("call set_data before call this method");
|
||||
return -1;
|
||||
}
|
||||
return this.packItems.findIndex(function (packItem) {
|
||||
return predicate(packItem.data);
|
||||
});
|
||||
};
|
||||
Object.defineProperty(ListView.prototype, "renderedItems", {
|
||||
get: function () {
|
||||
var items = [];
|
||||
for (var i = this.start_index; i <= this.stop_index; i++) {
|
||||
var packItem = this.packItems[i];
|
||||
if (packItem && packItem.item) {
|
||||
items.push(packItem.item);
|
||||
}
|
||||
}
|
||||
return items;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(ListView.prototype, "length", {
|
||||
get: function () {
|
||||
if (!this.packItems) {
|
||||
cc.log("call set_data before call this method");
|
||||
return 0;
|
||||
}
|
||||
return this.packItems.length;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
ListView.prototype.destroy = function () {
|
||||
this.clear_items();
|
||||
this.item_pool.forEach(function (item) {
|
||||
item.onUnInit();
|
||||
item.node.destroy();
|
||||
});
|
||||
this.item_pool = null;
|
||||
this.packItems = null;
|
||||
this.renderDirty = null;
|
||||
if (cc.isValid(this.scrollview.node)) {
|
||||
this.scrollview.node.off("scrolling", this.on_scrolling, this);
|
||||
this.scrollview.node.off("scroll-to-bottom", this.on_scroll_to_end, this);
|
||||
this.scrollview.node.off("scroll-to-right", this.on_scroll_to_end, this);
|
||||
this.scrollview.node.off(cc.Node.EventType.TOUCH_START, this.on_scroll_touch_start, this);
|
||||
this.scrollview.node.off(cc.Node.EventType.TOUCH_END, this.on_scroll_touch_end, this);
|
||||
this.scrollview.node.off(cc.Node.EventType.TOUCH_CANCEL, this.on_scroll_touch_cancel, this);
|
||||
}
|
||||
};
|
||||
Object.defineProperty(ListView.prototype, "selected_index", {
|
||||
get: function () {
|
||||
return this._selected_index;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(ListView.prototype, "selected_data", {
|
||||
get: function () {
|
||||
var packItem = this.packItems[this._selected_index];
|
||||
if (packItem) {
|
||||
return packItem.data;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(ListView.prototype, "scrollable", {
|
||||
set: function (value) {
|
||||
if (this.dir == ListViewDir.Vertical) {
|
||||
this.scrollview.vertical = value;
|
||||
}
|
||||
else {
|
||||
this.scrollview.horizontal = value;
|
||||
}
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(ListView.prototype, "startIndex", {
|
||||
get: function () {
|
||||
return this.start_index;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
Object.defineProperty(ListView.prototype, "stopIndex", {
|
||||
get: function () {
|
||||
return this.stop_index;
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
});
|
||||
return ListView;
|
||||
}());
|
||||
exports.ListView = ListView;
|
||||
var ListViewDir;
|
||||
(function (ListViewDir) {
|
||||
ListViewDir[ListViewDir["Vertical"] = 1] = "Vertical";
|
||||
ListViewDir[ListViewDir["Horizontal"] = 2] = "Horizontal";
|
||||
})(ListViewDir = exports.ListViewDir || (exports.ListViewDir = {}));
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.0.5",
|
||||
"uuid": "f4394ca7-5f81-4fbc-8a29-4361e05d601f",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
44
ListViewV2Demo/assets/Script/Listview-js/listviewitem.js
Normal file
44
ListViewV2Demo/assets/Script/Listview-js/listviewitem.js
Normal file
@@ -0,0 +1,44 @@
|
||||
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
|
||||
var ListViewItem = /** @class */ (function (_super) {
|
||||
__extends(ListViewItem, _super);
|
||||
function ListViewItem() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
// constructor()
|
||||
// {
|
||||
// super();
|
||||
// }
|
||||
ListViewItem.prototype.onInit = function () {
|
||||
// cc.log("item初如化");
|
||||
};
|
||||
ListViewItem.prototype.onUnInit = function () {
|
||||
// cc.log("item析构");
|
||||
};
|
||||
ListViewItem.prototype.onSetData = function (data, index) {
|
||||
// cc.log("item设置数据");
|
||||
};
|
||||
ListViewItem.prototype.onSetSelect = function (is_select, index) {
|
||||
// cc.log("item选中状态改变");
|
||||
};
|
||||
ListViewItem.prototype.onRecycle = function (data) {
|
||||
// cc.log("item被回收");
|
||||
};
|
||||
ListViewItem.prototype.onSelected = function (data, index) {
|
||||
// cc.log("item被选中");
|
||||
};
|
||||
ListViewItem.prototype.onTouchEnd = function (touchPos, data, index) {
|
||||
// cc.log("item非滑动状态下被点击");
|
||||
};
|
||||
ListViewItem.prototype.onBecameInvisible = function () {
|
||||
// cc.log("item从父节点移除或不可见");
|
||||
};
|
||||
ListViewItem.prototype.setLeftTop = function (left, top) {
|
||||
this.node.x = left + this.node.anchorX * this.node.width;
|
||||
this.node.y = top - (1 - this.node.anchorY) * this.node.height;
|
||||
};
|
||||
ListViewItem = __decorate([
|
||||
ccclass
|
||||
], ListViewItem);
|
||||
return ListViewItem;
|
||||
}(cc.Component));
|
||||
exports.ListViewItem = ListViewItem;
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.0.5",
|
||||
"uuid": "3cccd937-6bcc-49a5-bbc2-0e8ab9160951",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
5
ListViewV2Demo/assets/Script/Listview-ts.meta
Normal file
5
ListViewV2Demo/assets/Script/Listview-ts.meta
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"ver": "1.0.1",
|
||||
"uuid": "d7c5f4f4-fba1-4d5b-9ce5-8554c31e5629",
|
||||
"subMetas": {}
|
||||
}
|
||||
55
ListViewV2Demo/assets/Script/Listview-ts/ListViewItemTs.ts
Normal file
55
ListViewV2Demo/assets/Script/Listview-ts/ListViewItemTs.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
const {ccclass, property} = cc._decorator;
|
||||
@ccclass
|
||||
export class ListViewItemTs extends cc.Component
|
||||
{
|
||||
// constructor()
|
||||
// {
|
||||
// super();
|
||||
// }
|
||||
|
||||
onInit()
|
||||
{
|
||||
// cc.log("item初如化");
|
||||
}
|
||||
|
||||
onUnInit()
|
||||
{
|
||||
// cc.log("item析构");
|
||||
}
|
||||
|
||||
onSetData(data:any, index:number)
|
||||
{
|
||||
// cc.log("item设置数据");
|
||||
}
|
||||
|
||||
onSetSelect(is_select:boolean, index:number)
|
||||
{
|
||||
// cc.log("item选中状态改变");
|
||||
}
|
||||
|
||||
onRecycle(data:any)
|
||||
{
|
||||
// cc.log("item被回收");
|
||||
}
|
||||
|
||||
onSelected(data:any, index:number)
|
||||
{
|
||||
// cc.log("item被选中");
|
||||
}
|
||||
|
||||
onTouchEnd(touchPos:cc.Vec2, data:any, index:number)
|
||||
{
|
||||
// cc.log("item非滑动状态下被点击");
|
||||
}
|
||||
|
||||
onBecameInvisible()
|
||||
{
|
||||
// cc.log("item从父节点移除或不可见");
|
||||
}
|
||||
|
||||
setLeftTop(left:number, top:number)
|
||||
{
|
||||
this.node.x = left + this.node.anchorX * this.node.width;
|
||||
this.node.y = top - (1 - this.node.anchorY) * this.node.height;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.0.5",
|
||||
"uuid": "fde982ad-e299-424b-82b2-5b7ee89b266e",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
837
ListViewV2Demo/assets/Script/Listview-ts/ListViewTs.ts
Normal file
837
ListViewV2Demo/assets/Script/Listview-ts/ListViewTs.ts
Normal file
@@ -0,0 +1,837 @@
|
||||
import { LayoutUtilTs } from "./layout_utilsTs"
|
||||
import { ListViewItemTs } from "./ListViewItemTs";
|
||||
|
||||
export class ListViewTs {
|
||||
private scrollview: cc.ScrollView;
|
||||
private mask: cc.Mask;
|
||||
private content: cc.Node;
|
||||
private item_tpl: cc.Node;
|
||||
private item_pool: ListViewItemTs[];
|
||||
|
||||
private dir: number;
|
||||
private width: number;
|
||||
private height: number;
|
||||
private original_width: number;
|
||||
private original_height: number;
|
||||
private gap_x: number;
|
||||
private gap_y: number;
|
||||
private padding_left: number;
|
||||
private padding_right: number;
|
||||
private padding_top: number;
|
||||
private padding_bottom: number;
|
||||
private item_anchorX: number;
|
||||
private item_anchorY: number;
|
||||
private row: number;
|
||||
private col: number;
|
||||
private item_width: number;
|
||||
private item_height: number;
|
||||
private content_width: number;
|
||||
private content_height: number;
|
||||
private item_class: string;
|
||||
private cb_host: any;
|
||||
private scroll_to_end_cb: () => void;
|
||||
private auto_scrolling: boolean;
|
||||
private packItems: PackItem[];
|
||||
private start_index: number;
|
||||
private stop_index: number;
|
||||
private _selected_index: number = -1;
|
||||
private renderDirty: boolean;
|
||||
private timer: number;
|
||||
|
||||
constructor(params: ListViewParams) {
|
||||
this.scrollview = params.scrollview;
|
||||
this.mask = params.mask;
|
||||
this.content = params.content;
|
||||
this.item_tpl = params.item_tpl;
|
||||
this.item_tpl.active = false;
|
||||
this.item_width = this.item_tpl.width;
|
||||
this.item_height = this.item_tpl.height;
|
||||
this.dir = params.direction || ListViewDir.Vertical;
|
||||
this.width = params.width || this.scrollview.node.width;
|
||||
this.height = params.height || this.scrollview.node.height;
|
||||
this.gap_x = params.gap_x || 0;
|
||||
this.gap_y = params.gap_y || 0;
|
||||
this.padding_left = params.padding_left || 0;
|
||||
this.padding_right = params.padding_right || 0;
|
||||
this.padding_top = params.padding_top || 0;
|
||||
this.padding_bottom = params.padding_bottom || 0;
|
||||
this.item_anchorX = params.item_anchorX != null ? params.item_anchorX : 0;
|
||||
this.item_anchorY = params.item_anchorY != null ? params.item_anchorY : 1;
|
||||
this.row = params.row || 1;
|
||||
this.col = params.column || 1;
|
||||
this.cb_host = params.cb_host;
|
||||
this.scroll_to_end_cb = params.scroll_to_end_cb;
|
||||
this.item_class = params.item_class;
|
||||
this.auto_scrolling = params.auto_scrolling || false;
|
||||
this.item_pool = [];
|
||||
|
||||
if (this.dir == ListViewDir.Vertical) {
|
||||
const content_width = (this.item_width + this.gap_x) * this.col - this.gap_x + this.padding_left + this.padding_right;
|
||||
if (content_width > this.width) {
|
||||
cc.log("content_width > width, resize listview to content_width,", this.width, "->", content_width);
|
||||
this.width = content_width;
|
||||
}
|
||||
this.set_content_size(this.width, 0);
|
||||
}
|
||||
else {
|
||||
const content_height = (this.item_height + this.gap_y) * this.row - this.gap_y + this.padding_top + this.padding_bottom;
|
||||
if (content_height > this.height) {
|
||||
cc.log("content_height > height, resize listview to content_height,", this.height, "->", content_height);
|
||||
this.height = content_height;
|
||||
}
|
||||
this.set_content_size(0, this.height);
|
||||
}
|
||||
this.original_width = this.width;
|
||||
this.original_height = this.height;
|
||||
this.mask.node.setContentSize(this.width, this.height);
|
||||
this.scrollview.node.setContentSize(this.width, this.height);
|
||||
this.scrollview.vertical = this.dir == ListViewDir.Vertical;
|
||||
this.scrollview.horizontal = this.dir == ListViewDir.Horizontal;
|
||||
this.scrollview.inertia = true;
|
||||
this.scrollview.node.on("scrolling", this.on_scrolling, this);
|
||||
this.scrollview.node.on("scroll-to-bottom", this.on_scroll_to_end, this);
|
||||
this.scrollview.node.on("scroll-to-right", this.on_scroll_to_end, this);
|
||||
this.scrollview.node.on(cc.Node.EventType.TOUCH_START, this.on_scroll_touch_start, this);
|
||||
this.scrollview.node.on(cc.Node.EventType.TOUCH_END, this.on_scroll_touch_end, this);
|
||||
this.scrollview.node.on(cc.Node.EventType.TOUCH_CANCEL, this.on_scroll_touch_cancel, this);
|
||||
}
|
||||
|
||||
private _touchBeganPosition: cc.Vec2;
|
||||
private _touchEndPosition: cc.Vec2;
|
||||
private on_scroll_touch_start(event: cc.Event.EventTouch) {
|
||||
this._touchBeganPosition = cc.v2(event.touch.getLocation().x, event.touch.getLocation().y);
|
||||
}
|
||||
|
||||
private on_scroll_touch_cancel(event: cc.Event.EventTouch) {
|
||||
this._touchEndPosition = event.touch.getLocation();
|
||||
this.handle_release_logic();
|
||||
}
|
||||
|
||||
private on_scroll_touch_end(event: cc.Event.EventTouch) {
|
||||
this._touchEndPosition = event.touch.getLocation();
|
||||
this.handle_release_logic();
|
||||
}
|
||||
|
||||
private handle_release_logic() {
|
||||
const touchPos = this._touchEndPosition;
|
||||
const moveOffset = this._touchBeganPosition.sub(this._touchEndPosition);
|
||||
const dragDirection = this.get_drag_direction(moveOffset);
|
||||
if (dragDirection != 0) {
|
||||
return;
|
||||
}
|
||||
if (!this.packItems || !this.packItems.length) {
|
||||
return;
|
||||
}
|
||||
//无滑动的情况下点击
|
||||
const touchPosInContent = this.content.convertToNodeSpaceAR(touchPos);
|
||||
for (let i = this.start_index; i <= this.stop_index; i++) {
|
||||
const packItem = this.packItems[i];
|
||||
if (packItem && packItem.item && packItem.item.node.getBoundingBox().contains(touchPosInContent)) {
|
||||
packItem.item.onTouchEnd(packItem.item.node.convertToNodeSpaceAR(touchPos), packItem.data, i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private get_drag_direction(moveOffset: cc.Vec2) {
|
||||
if (this.dir === ListViewDir.Horizontal) {
|
||||
if (Math.abs(moveOffset.x) < 3) { return 0; }
|
||||
return (moveOffset.x > 0 ? 1 : -1);
|
||||
}
|
||||
else if (this.dir === ListViewDir.Vertical) {
|
||||
// 由于滚动 Y 轴的原点在在右上角所以应该是小于 0
|
||||
if (Math.abs(moveOffset.y) < 3) { return 0; }
|
||||
return (moveOffset.y < 0 ? 1 : -1);
|
||||
}
|
||||
}
|
||||
|
||||
private on_scroll_to_end() {
|
||||
if (this.scroll_to_end_cb) {
|
||||
this.scroll_to_end_cb.call(this.cb_host);
|
||||
}
|
||||
}
|
||||
|
||||
private last_content_pos: number;
|
||||
private on_scrolling() {
|
||||
let pos: number;
|
||||
let threshold: number;
|
||||
if (this.dir == ListViewDir.Vertical) {
|
||||
pos = this.content.y;
|
||||
threshold = this.item_height;
|
||||
}
|
||||
else {
|
||||
pos = this.content.x;
|
||||
threshold = this.item_width;
|
||||
}
|
||||
if (this.last_content_pos != null && Math.abs(pos - this.last_content_pos) < threshold) {
|
||||
return;
|
||||
}
|
||||
this.last_content_pos = pos;
|
||||
this.render();
|
||||
}
|
||||
|
||||
private render() {
|
||||
if (!this.packItems || !this.packItems.length) {
|
||||
return;
|
||||
}
|
||||
if (this.dir == ListViewDir.Vertical) {
|
||||
let posy = this.content.y;
|
||||
// cc.log("onscrolling, content posy=", posy);
|
||||
if (posy < 0) {
|
||||
posy = 0;
|
||||
}
|
||||
else if (posy > this.content_height - this.height) {
|
||||
posy = this.content_height - this.height;
|
||||
}
|
||||
let viewport_start = -posy;
|
||||
let viewport_stop = viewport_start - this.height;
|
||||
// while(this.packItems[start].y - this.item_height > viewport_start)
|
||||
// {
|
||||
// start++;
|
||||
// }
|
||||
// while(this.packItems[stop].y < viewport_stop)
|
||||
// {
|
||||
// stop--;
|
||||
// }
|
||||
let start = this.indexFromOffset(viewport_start);
|
||||
let stop = this.indexFromOffset(viewport_stop);
|
||||
|
||||
//expand viewport for better experience
|
||||
start = Math.max(start - this.col, 0);
|
||||
stop = Math.min(this.packItems.length - 1, stop + this.col);
|
||||
if (start != this.start_index) {
|
||||
this.start_index = start;
|
||||
this.renderDirty = true;
|
||||
}
|
||||
if (stop != this.stop_index) {
|
||||
this.stop_index = stop;
|
||||
this.renderDirty = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
let posx = this.content.x;
|
||||
// cc.log("onscrolling, content posx=", posx);
|
||||
if (posx > 0) {
|
||||
posx = 0;
|
||||
}
|
||||
else if (posx < this.width - this.content_width) {
|
||||
posx = this.width - this.content_width;
|
||||
}
|
||||
let viewport_start = -posx;
|
||||
let viewport_stop = viewport_start + this.width;
|
||||
// while(this.packItems[start].x + this.item_width < viewport_start)
|
||||
// {
|
||||
// start++;
|
||||
// }
|
||||
// while(this.packItems[stop].x > viewport_stop)
|
||||
// {
|
||||
// stop--;
|
||||
// }
|
||||
let start = this.indexFromOffset(viewport_start);
|
||||
let stop = this.indexFromOffset(viewport_stop);
|
||||
|
||||
//expand viewport for better experience
|
||||
start = Math.max(start - this.row, 0);
|
||||
stop = Math.min(this.packItems.length - 1, stop + this.row);
|
||||
if (start != this.start_index) {
|
||||
this.start_index = start;
|
||||
this.renderDirty = true;
|
||||
}
|
||||
if (stop != this.stop_index) {
|
||||
this.stop_index = stop;
|
||||
this.renderDirty = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onUpdate() {
|
||||
if (this.renderDirty && cc.isValid(this.scrollview.node)) {
|
||||
cc.log("listView, render_from:", this.start_index, this.stop_index);
|
||||
this.render_items();
|
||||
this.renderDirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
//不支持多行多列
|
||||
private indexFromOffset(offset: number) {
|
||||
let low = 0;
|
||||
let high = 0;
|
||||
let max_idx = 0;
|
||||
high = max_idx = this.packItems.length - 1;
|
||||
if (this.dir == ListViewDir.Vertical) {
|
||||
while (high >= low) {
|
||||
const index = low + Math.floor((high - low) / 2);
|
||||
const itemStart = this.packItems[index].y;
|
||||
const itemStop = index < max_idx ? this.packItems[index + 1].y : -this.content_height;
|
||||
if (offset <= itemStart && offset >= itemStop) {
|
||||
return index;
|
||||
}
|
||||
else if (offset > itemStart) {
|
||||
high = index - 1;
|
||||
}
|
||||
else {
|
||||
low = index + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
while (high >= low) {
|
||||
const index = low + Math.floor((high - low) / 2);
|
||||
const itemStart = this.packItems[index].x;
|
||||
const itemStop = index < max_idx ? this.packItems[index + 1].x : this.content_width;
|
||||
if (offset >= itemStart && offset <= itemStop) {
|
||||
return index;
|
||||
}
|
||||
else if (offset > itemStart) {
|
||||
low = index + 1;
|
||||
}
|
||||
else {
|
||||
high = index - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
select_data(data) {
|
||||
const idx = this.packItems.findIndex(item => item.data == data);
|
||||
if (idx != -1) {
|
||||
this.select_item(idx);
|
||||
}
|
||||
}
|
||||
|
||||
select_item(index: number) {
|
||||
if (index == this._selected_index) {
|
||||
return;
|
||||
}
|
||||
if (this._selected_index != -1) {
|
||||
this.inner_select_item(this._selected_index, false);
|
||||
}
|
||||
this._selected_index = index;
|
||||
this.inner_select_item(index, true);
|
||||
}
|
||||
|
||||
private inner_select_item(index: number, is_select: boolean) {
|
||||
let packItem: PackItem = this.packItems[index];
|
||||
if (!packItem) {
|
||||
cc.warn("inner_select_item index is out of range{", 0, this.packItems.length - 1, "}", index);
|
||||
return;
|
||||
}
|
||||
packItem.is_select = is_select;
|
||||
if (packItem.item) {
|
||||
packItem.item.onSetSelect(is_select, index);
|
||||
if (is_select) {
|
||||
packItem.item.onSelected(packItem.data, index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private spawn_item(index: number): ListViewItemTs {
|
||||
let item: ListViewItemTs = this.item_pool.pop();
|
||||
if (!item) {
|
||||
item = cc.instantiate(this.item_tpl).getComponent(this.item_class) as ListViewItemTs;
|
||||
item.node.active = true;
|
||||
//仅仅改变父节点锚点,子元素位置不会随之变化
|
||||
// item.node.setAnchorPoint(this.item_anchorX, this.item_anchorY);
|
||||
LayoutUtilTs.set_pivot_smart(item.node, this.item_anchorX, this.item_anchorY);
|
||||
item.onInit();
|
||||
// cc.log("spawn_item", index);
|
||||
}
|
||||
item.node.parent = this.content;
|
||||
return item;
|
||||
}
|
||||
|
||||
private recycle_item(packItem: PackItem) {
|
||||
const item = packItem.item;
|
||||
if (item && cc.isValid(item.node)) {
|
||||
item.onRecycle(packItem.data);
|
||||
item.node.removeFromParent();
|
||||
this.item_pool.push(item);
|
||||
packItem.item = null;
|
||||
}
|
||||
}
|
||||
|
||||
private clear_items() {
|
||||
if (this.packItems) {
|
||||
this.packItems.forEach(packItem => {
|
||||
this.recycle_item(packItem);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private render_items() {
|
||||
let packItem: PackItem;
|
||||
for (let i = 0; i < this.start_index; i++) {
|
||||
packItem = this.packItems[i];
|
||||
if (packItem.item) {
|
||||
// cc.log("recycle_item", i);
|
||||
this.recycle_item(packItem);
|
||||
}
|
||||
}
|
||||
for (let i = this.packItems.length - 1; i > this.stop_index; i--) {
|
||||
packItem = this.packItems[i];
|
||||
if (packItem.item) {
|
||||
// cc.log("recycle_item", i);
|
||||
this.recycle_item(packItem);
|
||||
}
|
||||
}
|
||||
for (let i = this.start_index; i <= this.stop_index; i++) {
|
||||
packItem = this.packItems[i];
|
||||
if (!packItem.item) {
|
||||
// cc.log("render_item", i);
|
||||
packItem.item = this.spawn_item(i);
|
||||
packItem.item.onSetData(packItem.data, i);
|
||||
packItem.item.onSetSelect(packItem.is_select, i);
|
||||
if (packItem.is_select) {
|
||||
packItem.item.onSelected(packItem.data, i);
|
||||
}
|
||||
}
|
||||
//列表添加与删除时item位置会变化,因此每次render_items都要执行
|
||||
// packItem.item.node.setPosition(packItem.x, packItem.y);
|
||||
packItem.item.setLeftTop(packItem.x, packItem.y);
|
||||
}
|
||||
}
|
||||
|
||||
private pack_item(data: any): PackItem {
|
||||
return { x: 0, y: 0, data: data, item: null, is_select: false };
|
||||
}
|
||||
|
||||
private layout_items(start: number) {
|
||||
// cc.log("layout_items, start=", start);
|
||||
for (let index = start, stop = this.packItems.length; index < stop; index++) {
|
||||
const packItem = this.packItems[index];
|
||||
if (this.dir == ListViewDir.Vertical) {
|
||||
[packItem.x, packItem.y] = LayoutUtilTs.vertical_layout(index, this.item_width, this.item_height, this.col, this.gap_x, this.gap_y, this.padding_left, this.padding_top);
|
||||
}
|
||||
else {
|
||||
[packItem.x, packItem.y] = LayoutUtilTs.horizontal_layout(index, this.item_width, this.item_height, this.row, this.gap_x, this.gap_y, this.padding_left, this.padding_top);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private adjust_content() {
|
||||
if (this.packItems.length <= 0) {
|
||||
this.set_content_size(0, 0);
|
||||
return;
|
||||
}
|
||||
const last_packItem = this.packItems[this.packItems.length - 1];
|
||||
if (this.dir == ListViewDir.Vertical) {
|
||||
const height = Math.max(this.height, this.item_height - last_packItem.y + this.padding_bottom);
|
||||
this.set_content_size(this.content_width, height);
|
||||
}
|
||||
else {
|
||||
const width = Math.max(this.width, last_packItem.x + this.item_width + this.padding_right);
|
||||
this.set_content_size(width, this.content_height);
|
||||
}
|
||||
}
|
||||
|
||||
private set_content_size(width: number, height: number) {
|
||||
if (this.content_width != width) {
|
||||
this.content_width = width;
|
||||
this.content.width = width;
|
||||
}
|
||||
if (this.content_height != height) {
|
||||
this.content_height = height;
|
||||
this.content.height = height;
|
||||
}
|
||||
// cc.log("ListView, set_content_size", width, height, this.content.width, this.content.height);
|
||||
}
|
||||
|
||||
set_viewport(width?: number, height?: number) {
|
||||
if (width == null) {
|
||||
width = this.width;
|
||||
}
|
||||
else if (width > this.content_width) {
|
||||
width = this.content_width;
|
||||
}
|
||||
|
||||
if (height == null) {
|
||||
height = this.height;
|
||||
}
|
||||
else if (height > this.content_height) {
|
||||
height = this.content_height;
|
||||
}
|
||||
//设置遮罩区域尺寸
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.mask.node.setContentSize(width, height);
|
||||
this.scrollview.node.setContentSize(width, height);
|
||||
this.render();
|
||||
}
|
||||
|
||||
renderAll(value: boolean) {
|
||||
let width: number;
|
||||
let height: number;
|
||||
if (value) {
|
||||
width = this.content_width;
|
||||
height = this.content_height;
|
||||
}
|
||||
else {
|
||||
width = this.original_width;
|
||||
height = this.original_height;
|
||||
}
|
||||
this.set_viewport(width, height);
|
||||
}
|
||||
|
||||
set_data(datas: any[]) {
|
||||
if (this.packItems) {
|
||||
this.clear_items();
|
||||
this.packItems.length = 0;
|
||||
}
|
||||
else {
|
||||
this.packItems = [];
|
||||
}
|
||||
datas.forEach(data => {
|
||||
let packItem = this.pack_item(data);
|
||||
this.packItems.push(packItem);
|
||||
});
|
||||
this.layout_items(0);
|
||||
this.adjust_content();
|
||||
this.start_index = -1;
|
||||
this.stop_index = -1;
|
||||
if (this.dir == ListViewDir.Vertical) {
|
||||
this.content.y = 0;
|
||||
}
|
||||
else {
|
||||
this.content.x = 0;
|
||||
}
|
||||
if (this.packItems.length > 0) {
|
||||
this.render();
|
||||
}
|
||||
}
|
||||
|
||||
insert_data(index: number, ...datas: any[]) {
|
||||
if (datas.length == 0) {
|
||||
cc.log("nothing to insert");
|
||||
return;
|
||||
}
|
||||
if (!this.packItems) {
|
||||
this.packItems = [];
|
||||
}
|
||||
if (index < 0 || index > this.packItems.length) {
|
||||
cc.warn("insert_data, invalid index", index);
|
||||
return;
|
||||
}
|
||||
let is_append = index == this.packItems.length;
|
||||
let packItems: PackItem[] = [];
|
||||
datas.forEach(data => {
|
||||
let packItem = this.pack_item(data);
|
||||
packItems.push(packItem);
|
||||
});
|
||||
this.packItems.splice(index, 0, ...packItems);
|
||||
this.layout_items(index);
|
||||
this.adjust_content();
|
||||
this.start_index = -1;
|
||||
this.stop_index = -1;
|
||||
|
||||
if (this.auto_scrolling && is_append) {
|
||||
this.scroll_to_end();
|
||||
}
|
||||
this.render();
|
||||
}
|
||||
|
||||
remove_data(index: number, count: number = 1) {
|
||||
if (!this.packItems) {
|
||||
cc.log("call set_data before call this method");
|
||||
return;
|
||||
}
|
||||
if (index < 0 || index >= this.packItems.length) {
|
||||
cc.warn("remove_data, invalid index", index);
|
||||
return;
|
||||
}
|
||||
if (count < 1) {
|
||||
cc.log("nothing to remove");
|
||||
return;
|
||||
}
|
||||
let old_length = this.packItems.length;
|
||||
let del_items = this.packItems.splice(index, count);
|
||||
//回收node
|
||||
del_items.forEach(packItem => {
|
||||
this.recycle_item(packItem);
|
||||
});
|
||||
|
||||
//重新排序index后面的
|
||||
if (index + count < old_length) {
|
||||
this.layout_items(index);
|
||||
}
|
||||
this.adjust_content();
|
||||
if (this.packItems.length > 0) {
|
||||
this.start_index = -1;
|
||||
this.stop_index = -1;
|
||||
this.render();
|
||||
}
|
||||
}
|
||||
|
||||
append_data(...datas: any[]) {
|
||||
if (!this.packItems) {
|
||||
this.packItems = [];
|
||||
}
|
||||
this.insert_data(this.packItems.length, ...datas);
|
||||
}
|
||||
|
||||
scroll_to(index: number, time = 0) {
|
||||
if (!this.packItems) {
|
||||
return;
|
||||
}
|
||||
const packItem = this.packItems[index];
|
||||
if (!packItem) {
|
||||
cc.log("scroll_to, index out of range");
|
||||
return;
|
||||
}
|
||||
if (this.dir == ListViewDir.Vertical) {
|
||||
const min_y = this.height - this.content_height;
|
||||
if (min_y >= 0) {
|
||||
cc.log("no need to scroll");
|
||||
return;
|
||||
}
|
||||
let y = packItem.y;
|
||||
if (y < min_y) {
|
||||
y = min_y;
|
||||
cc.log("content reach bottom");
|
||||
}
|
||||
const x = this.content.x;
|
||||
if (time == 0) {
|
||||
this.scrollview.setContentPosition(cc.v2(x, -y));
|
||||
}
|
||||
else {
|
||||
this.scrollview.scrollToOffset(cc.v2(x, -y), time);
|
||||
}
|
||||
this.render();
|
||||
}
|
||||
else {
|
||||
const max_x = this.content_width - this.width;
|
||||
if (max_x <= 0) {
|
||||
cc.log("no need to scroll");
|
||||
return;
|
||||
}
|
||||
let x = packItem.x;
|
||||
if (x > max_x) {
|
||||
x = max_x;
|
||||
cc.log("content reach right");
|
||||
}
|
||||
const y = this.content.y;
|
||||
if (time == 0) {
|
||||
this.scrollview.setContentPosition(cc.v2(-x, y));
|
||||
}
|
||||
else {
|
||||
this.scrollview.scrollToOffset(cc.v2(-x, y), time);
|
||||
}
|
||||
this.render();
|
||||
}
|
||||
}
|
||||
|
||||
get_scroll_offset() {
|
||||
const offset = this.scrollview.getScrollOffset();
|
||||
if (this.dir == ListViewDir.Vertical) {
|
||||
return offset.y;
|
||||
}
|
||||
else {
|
||||
return offset.x;
|
||||
}
|
||||
}
|
||||
|
||||
scroll_to_offset(value: number, time = 0) {
|
||||
if (this.dir == ListViewDir.Vertical) {
|
||||
const x = this.content.x;
|
||||
if (time == 0) {
|
||||
this.scrollview.setContentPosition(cc.v2(x, value));
|
||||
}
|
||||
else {
|
||||
this.scrollview.scrollToOffset(cc.v2(x, value), time);
|
||||
}
|
||||
this.render();
|
||||
}
|
||||
else {
|
||||
const y = this.content.y;
|
||||
if (time == 0) {
|
||||
this.scrollview.setContentPosition(cc.v2(value, y));
|
||||
}
|
||||
else {
|
||||
this.scrollview.scrollToOffset(cc.v2(value, y), time);
|
||||
}
|
||||
this.render();
|
||||
}
|
||||
}
|
||||
|
||||
scroll_to_end() {
|
||||
if (this.dir == ListViewDir.Vertical) {
|
||||
this.scrollview.scrollToBottom();
|
||||
}
|
||||
else {
|
||||
this.scrollview.scrollToRight();
|
||||
}
|
||||
}
|
||||
|
||||
refresh_item(index: number, data: any) {
|
||||
const packItem = this.get_pack_item(index);
|
||||
if (!packItem) {
|
||||
return;
|
||||
}
|
||||
const oldData = packItem.data;
|
||||
packItem.data = data;
|
||||
if (packItem.item) {
|
||||
packItem.item.onRecycle(oldData);
|
||||
packItem.item.onSetData(data, index);
|
||||
}
|
||||
}
|
||||
|
||||
reload_item(index: number) {
|
||||
const packItem = this.get_pack_item(index);
|
||||
if (packItem && packItem.item) {
|
||||
packItem.item.onRecycle(packItem.data);
|
||||
packItem.item.onSetData(packItem.data, index);
|
||||
}
|
||||
}
|
||||
|
||||
private get_pack_item(index: number) {
|
||||
if (!this.packItems) {
|
||||
cc.log("call set_data before call this method");
|
||||
return null;
|
||||
}
|
||||
if (index < 0 || index >= this.packItems.length) {
|
||||
cc.warn("get_pack_item, invalid index", index);
|
||||
return null;
|
||||
}
|
||||
return this.packItems[index];
|
||||
}
|
||||
|
||||
get_item(index: number) {
|
||||
const packItem = this.get_pack_item(index);
|
||||
return packItem ? packItem.item : null;
|
||||
}
|
||||
|
||||
get_data(index: number) {
|
||||
const packItem = this.get_pack_item(index);
|
||||
return packItem ? packItem.data : null;
|
||||
}
|
||||
|
||||
find_item(predicate: (data: any) => boolean) {
|
||||
if (!this.packItems || !this.packItems.length) {
|
||||
cc.log("call set_data before call this method");
|
||||
return null;
|
||||
}
|
||||
for (let i = this.start_index; i <= this.stop_index; i++) {
|
||||
const packItem = this.packItems[i];
|
||||
if (predicate(packItem.data)) {
|
||||
return packItem.item;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
find_index(predicate: (data: any) => boolean) {
|
||||
if (!this.packItems || !this.packItems.length) {
|
||||
cc.log("call set_data before call this method");
|
||||
return -1;
|
||||
}
|
||||
return this.packItems.findIndex(packItem => {
|
||||
return predicate(packItem.data);
|
||||
});
|
||||
}
|
||||
|
||||
get renderedItems() {
|
||||
const items: ListViewItemTs[] = [];
|
||||
for (let i = this.start_index; i <= this.stop_index; i++) {
|
||||
const packItem = this.packItems[i];
|
||||
if (packItem && packItem.item) {
|
||||
items.push(packItem.item);
|
||||
}
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
get length() {
|
||||
if (!this.packItems) {
|
||||
cc.log("call set_data before call this method");
|
||||
return 0;
|
||||
}
|
||||
return this.packItems.length;
|
||||
}
|
||||
|
||||
destroy() {
|
||||
this.clear_items();
|
||||
this.item_pool.forEach(item => {
|
||||
item.onUnInit();
|
||||
item.node.destroy();
|
||||
});
|
||||
this.item_pool = null;
|
||||
this.packItems = null;
|
||||
|
||||
this.renderDirty = null;
|
||||
|
||||
if (cc.isValid(this.scrollview.node)) {
|
||||
this.scrollview.node.off("scrolling", this.on_scrolling, this);
|
||||
this.scrollview.node.off("scroll-to-bottom", this.on_scroll_to_end, this);
|
||||
this.scrollview.node.off("scroll-to-right", this.on_scroll_to_end, this);
|
||||
this.scrollview.node.off(cc.Node.EventType.TOUCH_START, this.on_scroll_touch_start, this);
|
||||
this.scrollview.node.off(cc.Node.EventType.TOUCH_END, this.on_scroll_touch_end, this);
|
||||
this.scrollview.node.off(cc.Node.EventType.TOUCH_CANCEL, this.on_scroll_touch_cancel, this);
|
||||
}
|
||||
}
|
||||
|
||||
get selected_index(): number {
|
||||
return this._selected_index;
|
||||
}
|
||||
|
||||
get selected_data(): any {
|
||||
let packItem: PackItem = this.packItems[this._selected_index];
|
||||
if (packItem) {
|
||||
return packItem.data;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
set scrollable(value: boolean) {
|
||||
if (this.dir == ListViewDir.Vertical) {
|
||||
this.scrollview.vertical = value;
|
||||
}
|
||||
else {
|
||||
this.scrollview.horizontal = value;
|
||||
}
|
||||
}
|
||||
|
||||
get startIndex() {
|
||||
return this.start_index;
|
||||
}
|
||||
|
||||
get stopIndex() {
|
||||
return this.stop_index;
|
||||
}
|
||||
}
|
||||
|
||||
export enum ListViewDir {
|
||||
Vertical = 1,
|
||||
Horizontal = 2,
|
||||
}
|
||||
|
||||
type ListViewParams = {
|
||||
scrollview: cc.ScrollView;
|
||||
mask: cc.Mask;
|
||||
content: cc.Node;
|
||||
item_tpl: cc.Node;
|
||||
item_class: string; //item对应的类型
|
||||
direction?: ListViewDir;
|
||||
width?: number;
|
||||
height?: number;
|
||||
gap_x?: number;
|
||||
gap_y?: number;
|
||||
padding_left?: number;
|
||||
padding_right?: number;
|
||||
padding_top?: number;
|
||||
padding_bottom?: number;
|
||||
item_anchorX?: number;
|
||||
item_anchorY?: number;
|
||||
row?: number; //水平方向排版时,垂直方向上的行数
|
||||
column?: number; //垂直方向排版时,水平方向上的列数
|
||||
cb_host?: any; //回调函数host
|
||||
scroll_to_end_cb?: () => void; //滚动到尽头的回调
|
||||
auto_scrolling?: boolean; //append时自动滚动到尽头
|
||||
}
|
||||
|
||||
type PackItem = {
|
||||
x: number;
|
||||
y: number;
|
||||
data: any;
|
||||
is_select: boolean;
|
||||
item: ListViewItemTs;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.0.5",
|
||||
"uuid": "e19752a1-e897-4d61-af5d-b7175a60fc46",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
40
ListViewV2Demo/assets/Script/Listview-ts/layout_utilsTs.ts
Normal file
40
ListViewV2Demo/assets/Script/Listview-ts/layout_utilsTs.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
//item及父节点锚点都为(0,1)
|
||||
export class LayoutUtilTs
|
||||
{
|
||||
static vertical_layout(index:number, item_width:number, item_height:number, column = 1, gap_x = 0, gap_y = 0, padding_left = 0, padding_top = 0):[number, number]
|
||||
{
|
||||
const x = (index % column) * (item_width + gap_x) + padding_left;
|
||||
const y = -Math.floor(index / column) * (item_height + gap_y) - padding_top;
|
||||
return [x, y];
|
||||
}
|
||||
|
||||
static horizontal_layout(index:number, item_width:number, item_height:number, row = 1, gap_x = 0, gap_y = 0, padding_left = 0, padding_top = 0):[number, number]
|
||||
{
|
||||
const x = Math.floor(index / row) * (item_width + gap_x) + padding_left;
|
||||
const y = -(index % row) * (item_height + gap_y) - padding_top;
|
||||
return [x, y];
|
||||
}
|
||||
|
||||
static set_pivot_smart(node:cc.Node, ax:number, ay:number, recursive = false)
|
||||
{
|
||||
const deltaAx = ax - node.anchorX;
|
||||
const deltaAy = ay - node.anchorY;
|
||||
node.anchorX = ax;
|
||||
node.anchorY = ay;
|
||||
|
||||
//改变节点锚点,位置值相对锚点不变。需要调整节点至新位置才能保持一致视觉效果
|
||||
const deltaX = deltaAx * node.width;
|
||||
const deltaY = deltaAy * node.height;
|
||||
node.x += deltaX;
|
||||
node.y += deltaY;
|
||||
|
||||
node.children.forEach(child => {
|
||||
//父节点锚点改变,子节点相对父节点位置值不变,需要调整子节点至新位置才能保持一致视觉效果
|
||||
child.x -= deltaX;
|
||||
child.y -= deltaY;
|
||||
if(recursive) {
|
||||
LayoutUtil.set_pivot_smart(child, ax, ay);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.0.5",
|
||||
"uuid": "344364e7-c3e7-45e2-b395-f72dce66c455",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
63
ListViewV2Demo/assets/Script/TestListView-js.js
Normal file
63
ListViewV2Demo/assets/Script/TestListView-js.js
Normal file
@@ -0,0 +1,63 @@
|
||||
const ListView = require("listview").ListView;
|
||||
cc.Class({
|
||||
extends: cc.Component,
|
||||
|
||||
properties: {
|
||||
scrollview: cc.ScrollView,
|
||||
prefab: cc.Prefab,
|
||||
content: cc.Node,
|
||||
mask: cc.Mask,
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
let data = [];
|
||||
for (let i = 0; i < 100; i++) {
|
||||
data.push(i);
|
||||
}
|
||||
this.init(data);
|
||||
},
|
||||
|
||||
registerEvent() {
|
||||
|
||||
},
|
||||
|
||||
init(data) {
|
||||
let item = cc.instantiate(this.prefab);
|
||||
//初始化
|
||||
this.listView = new ListView({
|
||||
scrollview: this.scrollview,
|
||||
mask: this.mask,
|
||||
content: this.content,
|
||||
item_tpl: item,
|
||||
item_class: 'TestListViewItem-js',
|
||||
column: 2,
|
||||
gap_y: 5,
|
||||
gap_x: 5,
|
||||
});
|
||||
//显示
|
||||
this.listView.set_data(data);
|
||||
},
|
||||
|
||||
update(dt) {
|
||||
//刷新
|
||||
if (this.listView) {
|
||||
this.listView.onUpdate();
|
||||
}
|
||||
},
|
||||
|
||||
onEnable() {
|
||||
this.registerEvent();
|
||||
},
|
||||
|
||||
onDisable() {
|
||||
this.offEvent();
|
||||
},
|
||||
|
||||
offEvent() {
|
||||
//
|
||||
},
|
||||
|
||||
onDestroy() {
|
||||
|
||||
}
|
||||
});
|
||||
9
ListViewV2Demo/assets/Script/TestListView-js.js.meta
Normal file
9
ListViewV2Demo/assets/Script/TestListView-js.js.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.0.5",
|
||||
"uuid": "868729fd-53ab-4212-86c8-3f0b9d9f687f",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
54
ListViewV2Demo/assets/Script/TestListView-ts.ts
Normal file
54
ListViewV2Demo/assets/Script/TestListView-ts.ts
Normal file
@@ -0,0 +1,54 @@
|
||||
import { ListViewTs } from "./Listview-ts/listviewTs";
|
||||
|
||||
const { ccclass, property } = cc._decorator;
|
||||
|
||||
@ccclass
|
||||
export default class NewClass extends cc.Component {
|
||||
|
||||
@property(cc.ScrollView)
|
||||
scrollview: cc.ScrollView = null;
|
||||
@property(cc.Prefab)
|
||||
prefab: cc.Prefab = null;
|
||||
@property(cc.Node)
|
||||
content: cc.Node = null;
|
||||
@property(cc.Mask)
|
||||
mask: cc.Mask = null;
|
||||
listView: ListViewTs
|
||||
|
||||
onLoad() {
|
||||
console.log('abc');
|
||||
|
||||
let data = [];
|
||||
for (let i = 0; i < 100; i++) {
|
||||
data.push(i);
|
||||
}
|
||||
this.init(data);
|
||||
}
|
||||
|
||||
start() {
|
||||
|
||||
}
|
||||
|
||||
init(data) {
|
||||
let item = cc.instantiate(this.prefab);
|
||||
//初始化
|
||||
this.listView = new ListViewTs({
|
||||
scrollview: this.scrollview,
|
||||
mask: this.mask,
|
||||
content: this.content,
|
||||
item_tpl: item,
|
||||
item_class: 'TestListViewItem-js',
|
||||
column: 2,
|
||||
gap_y: 5,
|
||||
gap_x: 5,
|
||||
});
|
||||
//显示
|
||||
this.listView.set_data(data);
|
||||
}
|
||||
|
||||
update(dt) {
|
||||
if (this.listView) {
|
||||
this.listView.onUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
9
ListViewV2Demo/assets/Script/TestListView-ts.ts.meta
Normal file
9
ListViewV2Demo/assets/Script/TestListView-ts.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.0.5",
|
||||
"uuid": "93ce6ff4-9150-41e1-bf1c-346a95d0461e",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
55
ListViewV2Demo/assets/Script/TestListViewItem-js.js
Normal file
55
ListViewV2Demo/assets/Script/TestListViewItem-js.js
Normal file
@@ -0,0 +1,55 @@
|
||||
const ListViewItem = require("listviewitem").ListViewItem;
|
||||
cc.Class({
|
||||
extends: ListViewItem,
|
||||
|
||||
properties: {
|
||||
level: cc.Label,
|
||||
_data: null
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
|
||||
},
|
||||
|
||||
onInit() {
|
||||
// cc.log("item初如化");
|
||||
},
|
||||
|
||||
onUnInit() {
|
||||
// cc.log("item析构");
|
||||
},
|
||||
|
||||
onSetData(data, index) {
|
||||
cc.log("item设置数据");
|
||||
this._data = data;
|
||||
this.level.string = `data=${data}/index=${index}`;
|
||||
},
|
||||
|
||||
onSetSelect(is_select, index) {
|
||||
// cc.log("item选中状态改变");
|
||||
},
|
||||
|
||||
onRecycle(data) {
|
||||
// cc.log("item被回收");
|
||||
},
|
||||
|
||||
onSelected(data, index) {
|
||||
// cc.log("item被选中");
|
||||
},
|
||||
|
||||
onTouchEnd(touchPos/** : cc.Vec2*/, data, index) {
|
||||
// cc.log("item非滑动状态下被点击");
|
||||
|
||||
},
|
||||
|
||||
onBecameInvisible() {
|
||||
// cc.log("item从父节点移除或不可见");
|
||||
},
|
||||
|
||||
setLeftTop(left, top) {
|
||||
this.node.x = left + this.node.anchorX * this.node.width;
|
||||
this.node.y = top - (1 - this.node.anchorY) * this.node.height;
|
||||
},
|
||||
|
||||
|
||||
});
|
||||
9
ListViewV2Demo/assets/Script/TestListViewItem-js.js.meta
Normal file
9
ListViewV2Demo/assets/Script/TestListViewItem-js.js.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.0.5",
|
||||
"uuid": "a1b5d86a-886c-4292-a67f-28cd57ca60ff",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
28
ListViewV2Demo/assets/Script/TestListViewItem-ts.ts
Normal file
28
ListViewV2Demo/assets/Script/TestListViewItem-ts.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { ListViewItemTs } from "./Listview-ts/ListViewItemTs";
|
||||
|
||||
const { ccclass, property } = cc._decorator;
|
||||
|
||||
@ccclass
|
||||
export default class TestListView extends ListViewItemTs {
|
||||
|
||||
@property(cc.Label)
|
||||
label: cc.Label = null;
|
||||
|
||||
private _data: any;
|
||||
onLoad() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
onSetData(data: any, index: number) {
|
||||
cc.log("item设置数据");
|
||||
this._data = data;
|
||||
this.label.string = `data=${data}/index=${index}`;
|
||||
}
|
||||
|
||||
start() {
|
||||
|
||||
}
|
||||
|
||||
// update (dt) {}
|
||||
}
|
||||
9
ListViewV2Demo/assets/Script/TestListViewItem-ts.ts.meta
Normal file
9
ListViewV2Demo/assets/Script/TestListViewItem-ts.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.0.5",
|
||||
"uuid": "4d73084a-69f8-47f3-a5a3-5e6d2362a5a3",
|
||||
"isPlugin": false,
|
||||
"loadPluginInWeb": true,
|
||||
"loadPluginInNative": true,
|
||||
"loadPluginInEditor": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
6
ListViewV2Demo/assets/Texture.meta
Normal file
6
ListViewV2Demo/assets/Texture.meta
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"ver": "1.0.1",
|
||||
"uuid": "7b81d4e8-ec84-4716-968d-500ac1d78a54",
|
||||
"isGroup": false,
|
||||
"subMetas": {}
|
||||
}
|
||||
BIN
ListViewV2Demo/assets/Texture/HelloWorld.png
Normal file
BIN
ListViewV2Demo/assets/Texture/HelloWorld.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 37 KiB |
31
ListViewV2Demo/assets/Texture/HelloWorld.png.meta
Normal file
31
ListViewV2Demo/assets/Texture/HelloWorld.png.meta
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"ver": "2.2.0",
|
||||
"uuid": "6aa0aa6a-ebee-4155-a088-a687a6aadec4",
|
||||
"type": "sprite",
|
||||
"wrapMode": "clamp",
|
||||
"filterMode": "bilinear",
|
||||
"premultiplyAlpha": false,
|
||||
"subMetas": {
|
||||
"HelloWorld": {
|
||||
"ver": "1.0.3",
|
||||
"uuid": "31bc895a-c003-4566-a9f3-2e54ae1c17dc",
|
||||
"rawTextureUuid": "6aa0aa6a-ebee-4155-a088-a687a6aadec4",
|
||||
"trimType": "auto",
|
||||
"trimThreshold": 1,
|
||||
"rotated": false,
|
||||
"offsetX": 0,
|
||||
"offsetY": 0,
|
||||
"trimX": 0,
|
||||
"trimY": 0,
|
||||
"width": 195,
|
||||
"height": 270,
|
||||
"rawWidth": 195,
|
||||
"rawHeight": 270,
|
||||
"borderTop": 0,
|
||||
"borderBottom": 0,
|
||||
"borderLeft": 0,
|
||||
"borderRight": 0,
|
||||
"subMetas": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
ListViewV2Demo/assets/Texture/singleColor.png
Normal file
BIN
ListViewV2Demo/assets/Texture/singleColor.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
31
ListViewV2Demo/assets/Texture/singleColor.png.meta
Normal file
31
ListViewV2Demo/assets/Texture/singleColor.png.meta
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"ver": "2.2.0",
|
||||
"uuid": "a8027877-d8d6-4645-97a0-52d4a0123dba",
|
||||
"type": "sprite",
|
||||
"wrapMode": "clamp",
|
||||
"filterMode": "bilinear",
|
||||
"premultiplyAlpha": false,
|
||||
"subMetas": {
|
||||
"singleColor": {
|
||||
"ver": "1.0.3",
|
||||
"uuid": "410fb916-8721-4663-bab8-34397391ace7",
|
||||
"rawTextureUuid": "a8027877-d8d6-4645-97a0-52d4a0123dba",
|
||||
"trimType": "auto",
|
||||
"trimThreshold": 1,
|
||||
"rotated": false,
|
||||
"offsetX": 0,
|
||||
"offsetY": 0,
|
||||
"trimX": 0,
|
||||
"trimY": 0,
|
||||
"width": 2,
|
||||
"height": 2,
|
||||
"rawWidth": 2,
|
||||
"rawHeight": 2,
|
||||
"borderTop": 0,
|
||||
"borderBottom": 0,
|
||||
"borderLeft": 0,
|
||||
"borderRight": 0,
|
||||
"subMetas": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
20635
ListViewV2Demo/creator.d.ts
vendored
Normal file
20635
ListViewV2Demo/creator.d.ts
vendored
Normal file
File diff suppressed because it is too large
Load Diff
15
ListViewV2Demo/jsconfig.json
Normal file
15
ListViewV2Demo/jsconfig.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es6",
|
||||
"module": "commonjs",
|
||||
"experimentalDecorators": true
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
".vscode",
|
||||
"library",
|
||||
"local",
|
||||
"settings",
|
||||
"temp"
|
||||
]
|
||||
}
|
||||
4
ListViewV2Demo/project.json
Normal file
4
ListViewV2Demo/project.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"engine": "cocos2d-html5",
|
||||
"packages": "packages"
|
||||
}
|
||||
13
ListViewV2Demo/settings/builder.json
Normal file
13
ListViewV2Demo/settings/builder.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"excludeScenes": [],
|
||||
"orientation": {
|
||||
"landscapeLeft": true,
|
||||
"landscapeRight": true,
|
||||
"portrait": false,
|
||||
"upsideDown": false
|
||||
},
|
||||
"packageName": "org.cocos2d.helloworld",
|
||||
"startScene": "2d2f792f-a40c-49bb-a189-ed176a246e49",
|
||||
"title": "hello_world",
|
||||
"webOrientation": "auto"
|
||||
}
|
||||
7
ListViewV2Demo/settings/builder.panel.json
Normal file
7
ListViewV2Demo/settings/builder.panel.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"excludeScenes": [],
|
||||
"packageName": "org.cocos2d.helloworld",
|
||||
"platform": "web-mobile",
|
||||
"startScene": "2d2f792f-a40c-49bb-a189-ed176a246e49",
|
||||
"title": "HelloWorld"
|
||||
}
|
||||
34
ListViewV2Demo/settings/project.json
Normal file
34
ListViewV2Demo/settings/project.json
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"collision-matrix": [
|
||||
[
|
||||
true
|
||||
]
|
||||
],
|
||||
"excluded-modules": [],
|
||||
"group-list": [
|
||||
"default"
|
||||
],
|
||||
"start-scene": "current",
|
||||
"design-resolution-width": 960,
|
||||
"design-resolution-height": 640,
|
||||
"fit-width": false,
|
||||
"fit-height": true,
|
||||
"use-project-simulator-setting": false,
|
||||
"simulator-orientation": false,
|
||||
"use-customize-simulator": false,
|
||||
"simulator-resolution": {
|
||||
"width": 960,
|
||||
"height": 640
|
||||
},
|
||||
"last-module-event-record-time": 0,
|
||||
"facebook": {
|
||||
"enable": false,
|
||||
"appID": "",
|
||||
"live": {
|
||||
"enable": false
|
||||
},
|
||||
"audience": {
|
||||
"enable": false
|
||||
}
|
||||
}
|
||||
}
|
||||
133
ListViewV2Demo/settings/services.json
Normal file
133
ListViewV2Demo/settings/services.json
Normal file
@@ -0,0 +1,133 @@
|
||||
{
|
||||
"services": [
|
||||
{
|
||||
"service_id": "235",
|
||||
"service_name": "Cocos Analytics",
|
||||
"service_icon": "https://account.cocos.com/client/3f8f31ccf66995e183044f167c092395.png",
|
||||
"service_desc": "提供最核心最基本的数据、标准化界面功能简洁易用、数据准确性最好",
|
||||
"service_title": "精准了解游戏的新增、活跃、留存、付费等数据",
|
||||
"service_guide_url": "https://n-analytics.cocos.com/docs/",
|
||||
"service_sample_url": "https://github.com/cocos-creator/tutorial-dark-slash/tree/analytics",
|
||||
"service_dev_url": "http://analytics.cocos.com/realtime/jump_to/<app_id>",
|
||||
"service_type": "3",
|
||||
"service_type_zh": "公司和个人游戏",
|
||||
"support_platform": [
|
||||
"Android",
|
||||
"iOS",
|
||||
"HTML5"
|
||||
],
|
||||
"package_download_url": "http://download.cocos.com/CocosServices/plugins/service-analytics/1.2.0_2.1.0.zip",
|
||||
"package_version_desc": "1、优化SDK,修复H5-SDK 与多个小游戏平台适配问题,删除和优化init事件无用接口<br>2、 如有相关问题咨询或者需求, 可以联系我们技术支持邮箱 <a href=' '>support-cocos@cocos.com</a>",
|
||||
"service_component_name": "service-analytics",
|
||||
"package_versions": [
|
||||
"1.0.0_1.0.5",
|
||||
"1.1.2_2.0.0",
|
||||
"1.1.3_2.0.1",
|
||||
"1.1.4_2.0.1",
|
||||
"1.1.5_2.0.1",
|
||||
"1.1.6_2.0.1_2.0.2",
|
||||
"1.1.7_2.0.3",
|
||||
"1.1.8_2.0.4",
|
||||
"1.1.9_2.1.0",
|
||||
"1.2.0_2.1.0"
|
||||
],
|
||||
"build_platform": [
|
||||
"web-mobile",
|
||||
"web-desktop",
|
||||
"wechatgame",
|
||||
"android",
|
||||
"ios",
|
||||
"fb-instant-games",
|
||||
"android-instant",
|
||||
"baidugame",
|
||||
"quickgame",
|
||||
"qgame",
|
||||
"qqplay",
|
||||
"huawei"
|
||||
],
|
||||
"require_verify": 0,
|
||||
"service_price": "",
|
||||
"packpage_version_desc": "",
|
||||
"service_protocol": "游戏首次开启该服务时,Cocos会后台通知服务方为游戏开通服务并初始化参数,服务方根据需要可能会获取您的Cocos账户信息,包括账户基本资料、游戏基本资料、账户余额等,点击确认开通按钮即视为您同意该服务访问您的账户信息,详见<a href='http://auth.cocos.com/CocosServiceAgreement.html'>《Cocos用户服务协议》</a>和<a href='http://auth.cocos.com/PrivacyPolicy.html'>《Cocos隐私政策》</a>"
|
||||
},
|
||||
{
|
||||
"service_id": "241",
|
||||
"service_name": "Matchvs",
|
||||
"service_icon": "https://account.cocos.com/client/14406719a07eb3d714d36e5edc6e06fa.png",
|
||||
"service_desc": "通过SDK接入快速实现联网功能、帧同步、国内外多节点、服务器独立部署、gameServer自定义游戏服务端逻辑。\n技术支持群QQ群:822523258",
|
||||
"service_title": "专业成熟的移动游戏联网与服务端解决方案",
|
||||
"service_guide_url": "http://doc.matchvs.com/QuickStart/QuickStart-CocosCreator",
|
||||
"service_sample_url": "http://www.matchvs.com/serviceCourse",
|
||||
"service_dev_url": "http://www.matchvs.com/cocosLogin",
|
||||
"service_type": "3",
|
||||
"service_type_zh": "公司和个人游戏",
|
||||
"support_platform": [
|
||||
"Android",
|
||||
"iOS",
|
||||
"HTML5"
|
||||
],
|
||||
"package_download_url": "http://download.cocos.com/CocosServices/plugins/service-matchvs/1.0.7_3.7.9.6.zip",
|
||||
"package_version_desc": "更新日期:2019-05-15<br>更新内容:<br>1、调整getRoomListEx接口,获取系统创建房间<br>2、增加appkey等的校验<br>3、新增以下平台支持:<li>VIVO 小游戏<li>OPPO 小游戏<li>HUAWEI 快游戏<li>百度小游戏(默认不支持,需修改代码强制开启WSS选项)",
|
||||
"service_component_name": "service-matchvs",
|
||||
"package_versions": [
|
||||
"1.0.3_3.7.6.4",
|
||||
"1.0.5_3.7.7.3",
|
||||
"1.0.6_3.7.9.2",
|
||||
"1.0.7_3.7.9.6"
|
||||
],
|
||||
"build_platform": [
|
||||
"web-mobile",
|
||||
"web-desktop",
|
||||
"fb-instant-games",
|
||||
"wechatgame",
|
||||
"wechatgame-subcontext",
|
||||
"qqplay",
|
||||
"android",
|
||||
"android-instant",
|
||||
"ios",
|
||||
"mac",
|
||||
"quickgame",
|
||||
"qgame",
|
||||
"huawei"
|
||||
],
|
||||
"require_verify": 0,
|
||||
"service_price": "该服务按使用量计费,<a href='https://www.matchvs.com/price'><font color='#dddddd'>计费规则</font></a>,所产生的费用将由第三方从您的 <a href='https://account.cocos.com/#/finance/finance_list'><font color='#dddddd'>Cocos 账户余额</font></a> 中扣除。",
|
||||
"packpage_version_desc": "",
|
||||
"service_protocol": "游戏首次开启该服务时,Cocos会后台通知服务方为游戏开通服务并初始化参数,服务方根据需要可能会获取您的Cocos账户信息,包括账户基本资料、游戏基本资料、账户余额等,点击确认开通按钮即视为您同意该服务访问您的账户信息,详见<a href='http://auth.cocos.com/CocosServiceAgreement.html'>《Cocos用户服务协议》</a>和<a href='http://auth.cocos.com/PrivacyPolicy.html'>《Cocos隐私政策》</a>"
|
||||
},
|
||||
{
|
||||
"service_id": "242",
|
||||
"service_name": "Agora Voice",
|
||||
"service_icon": "https://account.cocos.com/uploads/client_icon/date(\"Y-m-d\")/50fe52b789c2fc1e1fff9eec161c1bb3.png",
|
||||
"service_desc": "稳定、低耗、76ms超低延时、全球200+数据中心覆盖;变声器、超高音质、听声辩位等丰富玩法极速接入;全平台支持:Android、iOS、Web。\n技术支持群QQ群:799099183\n",
|
||||
"service_title": "游戏内置实时语音",
|
||||
"service_guide_url": "https://docs.agora.io/cn/Interactive Gaming/game_c",
|
||||
"service_sample_url": "https://github.com/AgoraIO/Voice-Call-for-Mobile-Gaming/tree/master/Basic-Voice-Call-for-Gaming/Hello-Cocos-Creator-Voice-Agora",
|
||||
"service_dev_url": "https://sso.agora.io/api/oauth/cocos/login",
|
||||
"service_type": "3",
|
||||
"service_type_zh": "公司和个人游戏",
|
||||
"support_platform": [
|
||||
"Android",
|
||||
"iOS",
|
||||
"HTML5"
|
||||
],
|
||||
"package_download_url": "http://download.cocos.com/CocosServices/plugins/service-agora/1.0.2_2.2.3.20_2.5.2.zip",
|
||||
"package_version_desc": "解决Bug:onAudioVolumeIndication 回调收不到.",
|
||||
"service_component_name": "service-agora",
|
||||
"package_versions": [
|
||||
"1.0.1_2.2.3.20_2.5.2",
|
||||
"1.0.2_2.2.3.20_2.5.2"
|
||||
],
|
||||
"build_platform": [
|
||||
"web-mobile",
|
||||
"web-desktop",
|
||||
"android",
|
||||
"ios"
|
||||
],
|
||||
"require_verify": 1,
|
||||
"service_price": "该服务按使用量计费,<a href='https://docs.agora.io/cn/Agora Platform/billing_faq?platform=All Platforms'><font color='#dddddd'>计费规则</font></a>,所产生的费用将由第三方从您的 <a href='https://account.cocos.com/#/finance/finance_list'><font color='#dddddd'>Cocos 账户余额</font></a> 中扣除。",
|
||||
"packpage_version_desc": "",
|
||||
"service_protocol": "游戏首次开启该服务时,Cocos会后台通知服务方为游戏开通服务并初始化参数,服务方根据需要可能会获取您的Cocos账户信息,包括账户基本资料、游戏基本资料、账户余额等,点击确认开通按钮即视为您同意该服务访问您的账户信息,详见<a href='http://auth.cocos.com/CocosServiceAgreement.html'>《Cocos用户服务协议》</a>和<a href='http://auth.cocos.com/PrivacyPolicy.html'>《Cocos隐私政策》</a>"
|
||||
}
|
||||
]
|
||||
}
|
||||
BIN
ListViewV2Demo/template-banner.png
Normal file
BIN
ListViewV2Demo/template-banner.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 23 KiB |
5
ListViewV2Demo/template.json
Normal file
5
ListViewV2Demo/template.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"name": "TEMPLATES.helloworld.name",
|
||||
"desc": "TEMPLATES.helloworld.desc",
|
||||
"banner": "template-banner.png"
|
||||
}
|
||||
Reference in New Issue
Block a user