This commit is contained in:
o.o.c
2024-12-14 15:32:38 +08:00
commit 3c1e00b887
48 changed files with 37738 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
[InternetShortcut]
URL=https://docs.cocos.com/creator/manual/en/scripting/setup.html#custom-script-template

View File

@@ -0,0 +1,5 @@
{
"image": {
"type": "sprite-frame"
}
}

24
list-3x/.gitignore vendored Normal file
View File

@@ -0,0 +1,24 @@
#///////////////////////////
# Cocos Creator 3D Project
#///////////////////////////
library/
temp/
local/
build/
profiles/
native
#//////////////////////////
# NPM
#//////////////////////////
node_modules/
#//////////////////////////
# VSCode
#//////////////////////////
.vscode/
#//////////////////////////
# WebStorm
#//////////////////////////
.idea/

View File

@@ -0,0 +1,9 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "22474814-fac5-49b1-aece-dfc04017fc3f",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,416 @@
[
{
"__type__": "cc.Prefab",
"_name": "shape-label-cell",
"_objFlags": 0,
"__editorExtras__": {},
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 0,
"persistent": false
},
{
"__type__": "cc.Node",
"_name": "shape-label-cell",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": null,
"_children": [
{
"__id__": 2
},
{
"__id__": 10
}
],
"_active": true,
"_components": [
{
"__id__": 16
}
],
"_prefab": {
"__id__": 18
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_lrot": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_mobility": 0,
"_layer": 33554432,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": ""
},
{
"__type__": "cc.Node",
"_name": "shape",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 3
},
{
"__id__": 5
},
{
"__id__": 7
}
],
"_prefab": {
"__id__": 9
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_lrot": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_mobility": 0,
"_layer": 33554432,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": ""
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 2
},
"_enabled": true,
"__prefab": {
"__id__": 4
},
"_contentSize": {
"__type__": "cc.Size",
"width": 400,
"height": 200
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "38Ctl8rrVBIIzUsgoEVl18"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 2
},
"_enabled": true,
"__prefab": {
"__id__": 6
},
"_customMaterial": null,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 56,
"g": 81,
"b": 85,
"a": 255
},
"_spriteFrame": {
"__uuid__": "7d8f9b89-4fd1-4c9f-a3ab-38ec7cded7ca@f9941",
"__expectedType__": "cc.SpriteFrame"
},
"_type": 0,
"_fillType": 0,
"_sizeMode": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_useGrayscale": false,
"_atlas": null,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "e5z4rNsp5IqKHKYrZmbbGr"
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 2
},
"_enabled": true,
"__prefab": {
"__id__": 8
},
"_alignFlags": 45,
"_target": null,
"_left": 0,
"_right": 0,
"_top": 0,
"_bottom": 0,
"_horizontalCenter": 0,
"_verticalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 100,
"_originalHeight": 100,
"_alignMode": 1,
"_lockFlags": 45,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "16YuS9Y1RIHL3+RkLAY9ri"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "50E3C8mxhHcLBLSMVIqx2D",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
},
{
"__type__": "cc.Node",
"_name": "label",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": {
"__id__": 1
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 11
},
{
"__id__": 13
}
],
"_prefab": {
"__id__": 15
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_lrot": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_mobility": 0,
"_layer": 33554432,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": ""
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 10
},
"_enabled": true,
"__prefab": {
"__id__": 12
},
"_contentSize": {
"__type__": "cc.Size",
"width": 63.37689490176152,
"height": 50.4
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "227SaOS3lF15buT8rVMsrU"
},
{
"__type__": "cc.Label",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 10
},
"_enabled": true,
"__prefab": {
"__id__": 14
},
"_customMaterial": null,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_string": "label",
"_horizontalAlign": 1,
"_verticalAlign": 1,
"_actualFontSize": 34.59375,
"_fontSize": 30,
"_fontFamily": "Arial",
"_lineHeight": 40,
"_overflow": 0,
"_enableWrapText": true,
"_font": null,
"_isSystemFontUsed": true,
"_spacingX": 0,
"_isItalic": false,
"_isBold": false,
"_isUnderline": false,
"_underlineHeight": 2,
"_cacheMode": 0,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "452rD9FHJNEZN1iBdm4Ra3"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "db55RKuw1JC52K7YOxNE+s",
"instance": null,
"targetOverrides": null,
"nestedPrefabInstanceRoots": null
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 17
},
"_contentSize": {
"__type__": "cc.Size",
"width": 400,
"height": 200
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "65OHSX1lBN0p7gbe3Wj+iU"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "aanzQWNlJP9JX9MJIPpZk7",
"targetOverrides": null
}
]

View File

@@ -0,0 +1,13 @@
{
"ver": "1.1.45",
"importer": "prefab",
"imported": true,
"uuid": "c8b689a4-ae47-4041-8c9c-7298939e76be",
"files": [
".json"
],
"subMetas": {},
"userData": {
"syncNodeName": "shape-label-cell"
}
}

9
list-3x/assets/home.meta Normal file
View File

@@ -0,0 +1,9 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "46e5f5cb-a3ef-4dd6-a3e0-f2475af0089d",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,576 @@
[
{
"__type__": "cc.SceneAsset",
"_name": "home",
"_objFlags": 0,
"__editorExtras__": {},
"_native": "",
"scene": {
"__id__": 1
}
},
{
"__type__": "cc.Scene",
"_name": "home",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": null,
"_children": [
{
"__id__": 2
}
],
"_active": true,
"_components": [],
"_prefab": {
"__id__": 13
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_lrot": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_mobility": 0,
"_layer": 1073741824,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"autoReleaseAssets": false,
"_globals": {
"__id__": 14
},
"_id": "5d2f3c26-c7d2-48bd-bd13-ca5aa20a93c4"
},
{
"__type__": "cc.Node",
"_name": "Canvas",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": {
"__id__": 1
},
"_children": [
{
"__id__": 3
},
{
"__id__": 5
}
],
"_active": true,
"_components": [
{
"__id__": 9
},
{
"__id__": 10
},
{
"__id__": 11
},
{
"__id__": 12
}
],
"_prefab": null,
"_lpos": {
"__type__": "cc.Vec3",
"x": 640,
"y": 360.00000000000006,
"z": 0
},
"_lrot": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_mobility": 0,
"_layer": 33554432,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": "beI88Z2HpFELqR4T5EMHpg"
},
{
"__type__": "cc.Node",
"_name": "Camera",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": {
"__id__": 2
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 4
}
],
"_prefab": null,
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 1000
},
"_lrot": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_mobility": 0,
"_layer": 1073741824,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": "ebFwiq8gBFaYpqYbdoDODe"
},
{
"__type__": "cc.Camera",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 3
},
"_enabled": true,
"__prefab": null,
"_projection": 0,
"_priority": 0,
"_fov": 45,
"_fovAxis": 0,
"_orthoHeight": 481.3008130081301,
"_near": 0,
"_far": 1000,
"_color": {
"__type__": "cc.Color",
"r": 0,
"g": 0,
"b": 0,
"a": 255
},
"_depth": 1,
"_stencil": 0,
"_clearFlags": 7,
"_rect": {
"__type__": "cc.Rect",
"x": 0,
"y": 0,
"width": 1,
"height": 1
},
"_aperture": 19,
"_shutter": 7,
"_iso": 0,
"_screenScale": 1,
"_visibility": 1108344832,
"_targetTexture": null,
"_postProcess": null,
"_usePostProcess": false,
"_cameraType": -1,
"_trackingType": 0,
"_id": "63WIch3o5BEYRlXzTT0oWc"
},
{
"__type__": "cc.Node",
"_name": "list",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": {
"__id__": 2
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 6
},
{
"__id__": 7
}
],
"_prefab": null,
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_lrot": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_mobility": 0,
"_layer": 33554432,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": "d1/dCc9yNJ44lI4TRGfy4z"
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 5
},
"_enabled": true,
"__prefab": null,
"_contentSize": {
"__type__": "cc.Size",
"width": 400,
"height": 700
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": "315xpp6rxGVIpwfAByHAu2"
},
{
"__type__": "f94cbxum3xAsomhVNW1piY0",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 5
},
"_enabled": true,
"__prefab": null,
"mask": true,
"scrollEnabled": true,
"wheelScrollEnabled": true,
"scrollDirection": 1,
"mode": 0,
"preloadNodesLimitPerFrame": 2,
"frameInterval": 1,
"recycleInterval": 1,
"registerCellForEditor": [
{
"__id__": 8
}
],
"_id": "540sP7RuVMr66Fyji3wiJs"
},
{
"__type__": "_yx_editor_register_cell_info",
"prefab": {
"__uuid__": "c8b689a4-ae47-4041-8c9c-7298939e76be",
"__expectedType__": "cc.Prefab"
},
"identifier": "cell",
"comp": ""
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 2
},
"_enabled": true,
"__prefab": null,
"_contentSize": {
"__type__": "cc.Size",
"width": 1280,
"height": 720
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": "d6rUX5yfhMlKoWX2bSbawx"
},
{
"__type__": "cc.Canvas",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 2
},
"_enabled": true,
"__prefab": null,
"_cameraComponent": {
"__id__": 4
},
"_alignCanvasWithScreen": true,
"_id": "12O/ljcVlEqLmVm3U2gEOQ"
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 2
},
"_enabled": true,
"__prefab": null,
"_alignFlags": 45,
"_target": null,
"_left": 0,
"_right": 0,
"_top": 5.684341886080802e-14,
"_bottom": 5.684341886080802e-14,
"_horizontalCenter": 0,
"_verticalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 0,
"_originalHeight": 0,
"_alignMode": 2,
"_lockFlags": 0,
"_id": "c5V1EV8IpMtrIvY1OE9t2u"
},
{
"__type__": "f5a88umqwxKvohw3IWqZkJR",
"_name": "",
"_objFlags": 0,
"__editorExtras__": {},
"node": {
"__id__": 2
},
"_enabled": true,
"__prefab": null,
"listComp": {
"__id__": 7
},
"_id": "acPDbfi09KmLOkYo+Irf3Y"
},
{
"__type__": "cc.PrefabInfo",
"root": null,
"asset": null,
"fileId": "5d2f3c26-c7d2-48bd-bd13-ca5aa20a93c4",
"instance": null,
"targetOverrides": null
},
{
"__type__": "cc.SceneGlobals",
"ambient": {
"__id__": 15
},
"shadows": {
"__id__": 16
},
"_skybox": {
"__id__": 17
},
"fog": {
"__id__": 18
},
"octree": {
"__id__": 19
},
"skin": {
"__id__": 20
},
"lightProbeInfo": {
"__id__": 21
},
"bakedWithStationaryMainLight": false,
"bakedWithHighpLightmap": false
},
{
"__type__": "cc.AmbientInfo",
"_skyColorHDR": {
"__type__": "cc.Vec4",
"x": 0,
"y": 0,
"z": 0,
"w": 0.520833125
},
"_skyColor": {
"__type__": "cc.Vec4",
"x": 0,
"y": 0,
"z": 0,
"w": 0.520833125
},
"_skyIllumHDR": 20000,
"_skyIllum": 20000,
"_groundAlbedoHDR": {
"__type__": "cc.Vec4",
"x": 0,
"y": 0,
"z": 0,
"w": 0
},
"_groundAlbedo": {
"__type__": "cc.Vec4",
"x": 0,
"y": 0,
"z": 0,
"w": 0
},
"_skyColorLDR": {
"__type__": "cc.Vec4",
"x": 0.2,
"y": 0.5,
"z": 0.8,
"w": 1
},
"_skyIllumLDR": 20000,
"_groundAlbedoLDR": {
"__type__": "cc.Vec4",
"x": 0.2,
"y": 0.2,
"z": 0.2,
"w": 1
}
},
{
"__type__": "cc.ShadowsInfo",
"_enabled": false,
"_type": 0,
"_normal": {
"__type__": "cc.Vec3",
"x": 0,
"y": 1,
"z": 0
},
"_distance": 0,
"_shadowColor": {
"__type__": "cc.Color",
"r": 76,
"g": 76,
"b": 76,
"a": 255
},
"_maxReceived": 4,
"_size": {
"__type__": "cc.Vec2",
"x": 512,
"y": 512
}
},
{
"__type__": "cc.SkyboxInfo",
"_envLightingType": 0,
"_envmapHDR": null,
"_envmap": null,
"_envmapLDR": null,
"_diffuseMapHDR": null,
"_diffuseMapLDR": null,
"_enabled": false,
"_useHDR": true,
"_editableMaterial": null,
"_reflectionHDR": null,
"_reflectionLDR": null,
"_rotationAngle": 0
},
{
"__type__": "cc.FogInfo",
"_type": 0,
"_fogColor": {
"__type__": "cc.Color",
"r": 200,
"g": 200,
"b": 200,
"a": 255
},
"_enabled": false,
"_fogDensity": 0.3,
"_fogStart": 0.5,
"_fogEnd": 300,
"_fogAtten": 5,
"_fogTop": 1.5,
"_fogRange": 1.2,
"_accurate": false
},
{
"__type__": "cc.OctreeInfo",
"_enabled": false,
"_minPos": {
"__type__": "cc.Vec3",
"x": -1024,
"y": -1024,
"z": -1024
},
"_maxPos": {
"__type__": "cc.Vec3",
"x": 1024,
"y": 1024,
"z": 1024
},
"_depth": 8
},
{
"__type__": "cc.SkinInfo",
"_enabled": false,
"_blurRadius": 0.01,
"_sssIntensity": 3
},
{
"__type__": "cc.LightProbeInfo",
"_giScale": 1,
"_giSamples": 1024,
"_bounces": 2,
"_reduceRinging": 0,
"_showProbe": true,
"_showWireframe": true,
"_showConvex": false,
"_data": null,
"_lightProbeSphereVolume": 1
}
]

View File

@@ -0,0 +1,11 @@
{
"ver": "1.1.45",
"importer": "scene",
"imported": true,
"uuid": "5d2f3c26-c7d2-48bd-bd13-ca5aa20a93c4",
"files": [
".json"
],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,53 @@
import { _decorator, Component, Label, math, Node } from 'cc';
import { YXCollectionView } from '../lib/yx-collection-view';
import { YXTableLayout } from '../lib/yx-table-layout';
const { ccclass, property } = _decorator;
class Data {
id: number
}
@ccclass('home')
export class home extends Component {
@property(YXCollectionView)
listComp: YXCollectionView = null
testData: Data[] = []
protected start(): void {
// 绑定数据源
this.listComp.numberOfItems = () => this.testData.length
this.listComp.cellForItemAt = (indexPath, collectionView) => {
const rowData = this.testData[indexPath.item]
const cell = collectionView.dequeueReusableCell(`cell`)
cell.getChildByName('label').getComponent(Label).string = `${indexPath}`
return cell
}
// 确定布局方案
let layout = new YXTableLayout()
layout.spacing = 20
layout.itemSize = new math.Size(400, 100)
this.listComp.layout = layout
this.receivedData()
}
/**
* 模拟收到数据
*/
receivedData() {
this.testData = []
for (let index = 0; index < 1000; index++) {
let data = new Data()
data.id = index
this.testData.push(data)
}
// 刷新列表
this.listComp.reloadData()
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "f5a88ba6-ab0c-4abe-8870-dc85aa664251",
"files": [],
"subMetas": {},
"userData": {}
}

9
list-3x/assets/lib.meta Normal file
View File

@@ -0,0 +1,9 @@
{
"ver": "1.2.0",
"importer": "directory",
"imported": true,
"uuid": "bf1ca834-a556-4dcc-a699-1a5c368bda61",
"files": [],
"subMetas": {},
"userData": {}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "f94cbc6e-9b7c-40b2-89a1-54d5b5a62634",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,115 @@
import { math, UITransform, warn } from "cc";
import { YXBinaryLayout, YXCollectionView, YXIndexPath, YXLayoutAttributes } from "./yx-collection-view";
enum _yx_table_layout_alignment {
/**
* 单元节点相对列表居中
*/
CENTER,
/**
* 单元节点紧靠列表左侧
*/
LEFT,
/**
* 单元节点紧靠列表右侧
*/
RIGHT,
}
/**
* 想要了解自定义布局的,可以看看这个类,这个类实现了一个基础的 table view 的布局样式,相对来说比较简单
*
* - 支持不同的节点大小
* - 支持调整对齐方式
* - 不支持分区布局
* - 不支持水平方向滚动,仅支持垂直方向滚动
* - 不支持多列布局,仅支持单列布局
* - 支持调整上下边距/间距
*/
export class YXTableLayout extends YXBinaryLayout {
/**
* 单元格大小
*/
itemSize: math.Size | ((indexPath: YXIndexPath, layout: YXTableLayout, collectionView: YXCollectionView) => math.Size) = new math.Size(100, 100)
/**
* 间距
*/
spacing: number = 0
/**
* 上边距
*/
top: number = 0
/**
* 下边距
*/
bottom: number = 0
/**
* 对齐方式
*/
alignment: _yx_table_layout_alignment = YXTableLayout.Alignment.CENTER
static Alignment = _yx_table_layout_alignment
prepare(collectionView: YXCollectionView): void {
// 设置列表的滚动方向
if (collectionView.scrollDirection == YXCollectionView.ScrollDirection.HORIZONTAL) {
warn(`YXTableLayout 只支持垂直方向排列`)
}
collectionView.scrollView.horizontal = false
collectionView.scrollView.vertical = true
let contentSize = collectionView.node.getComponent(UITransform).contentSize.clone()
let attrs = []
let maxY = this.top
// 获取列表内一共需要展示多少数据
let numberOfItems = collectionView.getNumberOfItems(0)
for (let row = 0; row < numberOfItems; row++) {
// 生成对应的 indexPath并通过 indexPath 获取节点大小
// 这里是不支持分区所以不考虑 section 的情况section 默认就是 0支持的分区的情况可以回头看 flow-layout 的实现
let indexPath = new YXIndexPath(0, row)
let itemSize = this.itemSize instanceof Function ? this.itemSize(indexPath, this, collectionView) : this.itemSize
// 生成布局属性对象,并按照 table view 的规则确定好节点的位置
let attributes = new YXLayoutAttributes(indexPath)
attributes.frame = new math.Rect()
attributes.frame.size = itemSize
attributes.frame.y = maxY + (row > 0 ? this.spacing : 0)
attributes.frame.x = 0
if (this.alignment == _yx_table_layout_alignment.RIGHT) {
attributes.frame.x = (contentSize.width - attributes.frame.width)
}
if (this.alignment == _yx_table_layout_alignment.CENTER) {
attributes.frame.x = (contentSize.width - attributes.frame.width) * 0.5
}
attrs.push(attributes)
maxY = attributes.frame.yMax
}
maxY += this.bottom
// 保存起来给列表组件使用
this.attributes = attrs
// 确定滚动范围的总大小
contentSize.height = Math.max(contentSize.height, maxY)
this.contentSize = contentSize
}
initOffset(collectionView: YXCollectionView): void {
// 首次更新数据,滚动至列表顶部
collectionView.scrollView.scrollToTop()
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "0187d4ab-fbb6-44aa-8c36-b5709f3dbff4",
"files": [],
"subMetas": {},
"userData": {}
}

7
list-3x/package.json Executable file
View File

@@ -0,0 +1,7 @@
{
"name": "list-3x",
"uuid": "d21c5c56-bc81-481d-b241-7ce394501071",
"creator": {
"version": "3.8.0"
}
}

View File

@@ -0,0 +1,3 @@
{
"__version__": "1.3.6"
}

View File

@@ -0,0 +1,23 @@
{
"__version__": "3.0.7",
"game": {
"name": "未知游戏",
"app_id": "UNKNOW",
"c_id": "0"
},
"appConfigMaps": [
{
"app_id": "UNKNOW",
"config_id": "abc178"
}
],
"configs": [
{
"app_id": "UNKNOW",
"config_id": "abc178",
"config_name": "Default",
"config_remarks": "",
"services": []
}
]
}

View File

@@ -0,0 +1,3 @@
{
"__version__": "1.0.1"
}

View File

@@ -0,0 +1,150 @@
{
"__version__": "1.0.7",
"modules": {
"cache": {
"base": {
"_value": true
},
"graphcis": {
"_value": true
},
"gfx-webgl": {
"_value": true
},
"gfx-webgl2": {
"_value": true
},
"animation": {
"_value": true
},
"skeletal-animation": {
"_value": false
},
"3d": {
"_value": false
},
"2d": {
"_value": true
},
"xr": {
"_value": false
},
"ui": {
"_value": true
},
"particle": {
"_value": false
},
"physics": {
"_value": false,
"_option": "physics-ammo"
},
"physics-ammo": {
"_value": false
},
"physics-cannon": {
"_value": false
},
"physics-physx": {
"_value": false
},
"physics-builtin": {
"_value": false
},
"physics-2d": {
"_value": true,
"_option": "physics-2d-box2d"
},
"physics-2d-box2d": {
"_value": false
},
"physics-2d-builtin": {
"_value": false
},
"intersection-2d": {
"_value": true
},
"primitive": {
"_value": false
},
"profiler": {
"_value": true
},
"occlusion-query": {
"_value": false
},
"geometry-renderer": {
"_value": false
},
"debug-renderer": {
"_value": false
},
"particle-2d": {
"_value": true
},
"audio": {
"_value": true
},
"video": {
"_value": true
},
"webview": {
"_value": true
},
"tween": {
"_value": true
},
"websocket": {
"_value": false
},
"websocket-server": {
"_value": false
},
"terrain": {
"_value": false
},
"light-probe": {
"_value": false
},
"tiled-map": {
"_value": true
},
"spine": {
"_value": true
},
"dragon-bones": {
"_value": true
},
"marionette": {
"_value": false
},
"custom-pipeline": {
"_value": false
}
},
"includeModules": [
"2d",
"animation",
"audio",
"base",
"dragon-bones",
"gfx-webgl",
"gfx-webgl2",
"intersection-2d",
"particle-2d",
"physics-2d-box2d",
"profiler",
"spine",
"tiled-map",
"tween",
"ui",
"video",
"webview"
],
"noDeprecatedFeatures": {
"value": false,
"version": ""
},
"flags": {}
}
}

View File

@@ -0,0 +1,23 @@
{
"__version__": "1.0.0",
"information": {
"customSplash": {
"id": "customSplash",
"label": "customSplash",
"enable": true,
"customSplash": {
"complete": false,
"form": "https://creator-api.cocos.com/api/form/show?sid=9fcf74f056ee5fdb06fa23517bdcc30a"
}
},
"removeSplash": {
"id": "removeSplash",
"label": "removeSplash",
"enable": true,
"removeSplash": {
"complete": false,
"form": "https://creator-api.cocos.com/api/form/show?sid=9fcf74f056ee5fdb06fa23517bdcc30a"
}
}
}
}

View File

@@ -0,0 +1,3 @@
{
"__version__": "1.0.3"
}

View File

@@ -0,0 +1,3 @@
{
"__version__": "1.0.5"
}

9
list-3x/tsconfig.json Normal file
View File

@@ -0,0 +1,9 @@
{
/* Base configuration. Do not edit this field. */
"extends": "./temp/tsconfig.cocos.json",
/* Add your custom configuration here. */
"compilerOptions": {
"strict": false
}
}