diff --git a/ListViewV2Demo/assets/Scene/helloworldTs.fire b/ListViewV2Demo/assets/Scene/helloworldTs.fire index 9b8a106..1bd4a52 100644 --- a/ListViewV2Demo/assets/Scene/helloworldTs.fire +++ b/ListViewV2Demo/assets/Scene/helloworldTs.fire @@ -66,10 +66,10 @@ "_active": true, "_components": [ { - "__id__": 13 + "__id__": 15 }, { - "__id__": 14 + "__id__": 16 } ], "_prefab": null, @@ -231,14 +231,17 @@ "_tag": -1, "_active": true, "_components": [ - { - "__id__": 10 - }, { "__id__": 11 }, { "__id__": 12 + }, + { + "__id__": 13 + }, + { + "__id__": 14 } ], "_prefab": null, @@ -295,6 +298,9 @@ "_components": [ { "__id__": 9 + }, + { + "__id__": 10 } ], "_prefab": null, @@ -382,6 +388,34 @@ "_opacityModifyRGB": false, "groupIndex": 0 }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 7 + }, + "_enabled": true, + "isAlignOnce": true, + "_target": { + "__id__": 2 + }, + "_alignFlags": 40, + "_left": 130, + "_right": 130, + "_top": 0, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 700, + "_originalHeight": 0 + }, { "__type__": "cc.Mask", "_name": "", @@ -422,6 +456,34 @@ "_dstBlendFactor": 771, "_atlas": null }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 6 + }, + "_enabled": true, + "isAlignOnce": true, + "_target": { + "__id__": 2 + }, + "_alignFlags": 40, + "_left": 130, + "_right": 130, + "_top": 185, + "_bottom": 185, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 700, + "_originalHeight": 270 + }, { "__type__": "cc.ScrollView", "_name": "", @@ -453,13 +515,13 @@ }, "_enabled": true, "scrollview": { - "__id__": 11 + "__id__": 13 }, "content": { "__id__": 8 }, "mask": { - "__id__": 9 + "__id__": 10 }, "prefab": { "__uuid__": "10c60cf0-420d-41d3-b409-ae1ebad07af7" diff --git a/ListViewV2Demo/assets/Script/ListViewFactory.ts b/ListViewV2Demo/assets/Script/ListViewFactory.ts index 417106a..1135500 100644 --- a/ListViewV2Demo/assets/Script/ListViewFactory.ts +++ b/ListViewV2Demo/assets/Script/ListViewFactory.ts @@ -1,4 +1,4 @@ -import { ListViewTs } from "./Listview/listview"; +import { ListViewTs, ListViewParams } from "./Listview/listview"; const { ccclass, property } = cc._decorator; @@ -36,7 +36,14 @@ export default class ListViewFactory extends cc.Component { listView: ListViewTs; - init(data) { + init(data: Array) { + //下一帧执行,当使用widget适配高宽,可以取得真实长度。 + this.scheduleOnce(() => { + this._init(data); + }, 0); + } + + _init(data: Array) { //初始化 let item = cc.instantiate(this.prefab); this.listView = new ListViewTs({ diff --git a/ListViewV2Demo/assets/Script/Listview/ListView.ts b/ListViewV2Demo/assets/Script/Listview/ListView.ts index 7edd263..e947d4f 100644 --- a/ListViewV2Demo/assets/Script/Listview/ListView.ts +++ b/ListViewV2Demo/assets/Script/Listview/ListView.ts @@ -804,7 +804,7 @@ export enum ListViewDir { Horizontal = 2, } -type ListViewParams = { +export type ListViewParams = { scrollview: cc.ScrollView; mask: cc.Mask; content: cc.Node;