[add] all

This commit is contained in:
2022-01-13 09:27:08 +08:00
commit 8247d8a88e
79 changed files with 41174 additions and 0 deletions

BIN
assets/scripts/.DS_Store vendored Normal file

Binary file not shown.

View File

@@ -0,0 +1,19 @@
import Simple from './simple';
const { ccclass, property } = cc._decorator;
@ccclass
export default class AutoCenter extends Simple {
@property(cc.Label) label: cc.Label = null
@property key: string = ""
start() {
this.label.string = `当前中心锚点:${(this.layout.centerAnchor as any)[this.key]}`
}
onInputAnchor(event: cc.EditBox) {
let anchor = Number(event.string)
if (isNaN(anchor)) return
(this.layout.centerAnchor as any)[this.key] = anchor
this.layout.scrollToCenter()
this.label.string = `当前中心锚点:${(this.layout.centerAnchor as any)[this.key]}`
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "1.0.8",
"uuid": "59a8d94e-6ce6-4056-b3b7-4bbfbd2d7f13",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@@ -0,0 +1,24 @@
const { ccclass, property } = cc._decorator;
@ccclass
export default class BaseItem extends cc.Component {
@property(cc.Label) label: cc.Label = null
@property(cc.EditBox) input: cc.EditBox = null
private index: number
private clickFunc: Function
get transform() {
return this.node
}
show(data: any, index: number, callback: Function) {
this.index = index
this.label.string = data.message
this.clickFunc = callback
}
onClick() {
this.clickFunc.call(this, this.index)
}
onInput() {
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "1.0.8",
"uuid": "f929691e-8d80-45ca-94b7-83348ac4379e",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@@ -0,0 +1,42 @@
import SuperLayout from '../core/super-layout';
import BaseItem from './baseItem';
const { ccclass, property } = cc._decorator;
@ccclass
export default class BaseMain extends cc.Component {
@property(SuperLayout) layout: SuperLayout = null
@property(cc.EditBox) input: cc.EditBox = null
protected datas: any[] = []
toHeader() {
this.layout.scrollToHeader(1)
}
toFooter() {
this.layout.scrollToFooter(1)
}
toIndex() {
var index = Number(this.input.string)
if (isNaN(index)) return
this.layout.scrollToIndex(index, 1)
}
toBack() {
cc.director.loadScene("main")
}
onRefreshEvent(item: cc.Node, index: number) {
item.getComponent(BaseItem).show(this.datas[index], index, this.onClickItem.bind(this))
}
onClickItem(index: number) {
this.datas.splice(index, 1)
this.layout.total(this.datas.length)
}
addItem(event: any, args: any) {
let count = Number(args)
if (isNaN(count)) return
for (let i = 0; i < count; i++) {
this.datas.push({ message: this.datas.length })
}
this.layout.total(this.datas.length)
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "1.0.8",
"uuid": "556e96b5-e975-4595-8541-e1ab590e163f",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@@ -0,0 +1,18 @@
import BaseItem from './baseItem';
const { ccclass, property } = cc._decorator;
@ccclass
export default class Horizontal extends BaseItem {
onLoad() {
this.input.placeholder = this.transform.width.toString()
}
onInput() {
let width = Number(this.input.string)
if (isNaN(width)) return
if (width < 100) {
return
}
this.transform.setContentSize(new cc.Size(Number(this.input.string), this.transform.height))
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "1.0.8",
"uuid": "6c7ecf78-01a9-4555-b915-6c3253e68ce2",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

10
assets/scripts/main.ts Normal file
View File

@@ -0,0 +1,10 @@
const { ccclass, property } = cc._decorator;
@ccclass
export default class Main extends cc.Component {
toScene(event:any,args:string){
cc.director.loadScene(args)
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "1.0.8",
"uuid": "d349c267-15e9-4070-8d83-72c48d3a9550",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

26
assets/scripts/page.ts Normal file
View File

@@ -0,0 +1,26 @@
import SuperLayout from '../core/super-layout';
import BaseItem from './baseItem';
import BaseMain from './baseMain';
const { ccclass, property } = cc._decorator;
@ccclass
export default class Page extends BaseMain {
start() {
for (let i = 0; i < 8; i++) {
this.datas.push({
message: i
})
}
this.layout.total(this.datas.length)
}
onRefreshEvent(item: cc.Node, index: number) {
item.getComponent(BaseItem).show(this.datas[index], index, this.onClickItem.bind(this))
}
onClickItem() {
}
onPageEvent(event: any) {
console.error(this.layout.currPageIndex)
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "1.0.8",
"uuid": "4a48eb73-367c-4cea-a3b6-2470f795a1ff",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@@ -0,0 +1,93 @@
import BaseMain from './baseMain';
const { ccclass, property } = cc._decorator;
@ccclass
export default class RefreshLoad extends BaseMain {
@property(cc.Node) header: cc.Node = null
@property(cc.Node) footer: cc.Node = null
onLoad() {
this.header.setScale(new cc.Vec3(1, 0, 1))
this.footer.setScale(new cc.Vec3(1, 0, 1))
}
private headerTween: cc.Tween<cc.Node>
private footerTween: cc.Tween<cc.Node>
onHeader(scrollView: any, event: any) {
if (event.progress > 2) {
if (!(this.header as any)['playing']) {
this.headerTween = new cc.Tween(this.header);
this.headerTween.to(0.518, {
scaleX: 1,
scaleY: 1,
}, {
easing: "elasticOut"
});
this.headerTween.start();
(this.header as any)['playing'] = true
}
} else {
this.headerTween && this.headerTween.stop();
(this.header as any)['playing'] = false
this.header.setScale(new cc.Vec3(1, event.progress, 1))
}
let label = this.header.getComponentInChildren(cc.Label)
if (event.stage == "touch") {
label.string = "↓ 继续下拉"
}
if (event.stage == "wait") {
label.string = "↑ 松开刷新"
}
if (event.stage == "lock") {
label.string = this.datas.length == 0 ? "没有数据" : "刷新中..."
}
if (event.stage == 'release') {
label.string = ""
}
if (event.action) {
this.scheduleOnce(() => this.layout.total(this.datas.length), 1)
}
}
onFooter(scrollView: any, event: any) {
if (event.progress > 2) {
if (!(this.footer as any)['playing']) {
this.footerTween = new cc.Tween(this.footer);
this.footerTween.to(0.518, {
scaleX: 1,
scaleY: 1,
}, {
easing: "elasticOut"
});
this.footerTween.start();
(this.footer as any)['playing'] = true
}
} else {
this.footerTween && this.footerTween.stop();
(this.footer as any)['playing'] = false
this.footer.setScale(new cc.Vec3(1, event.progress, 1))
}
let label = this.footer.getComponentInChildren(cc.Label)
if (event.stage == "touch") {
label.string = "↑ 继续上拉"
}
if (event.stage == "wait") {
label.string = "↓ 松开加载"
}
if (event.stage == "lock") {
label.string = "加载中..."
}
if (event.stage == 'release') {
label.string = ""
}
if (event.action) {
for (let i = 0; i < 60; i++) {
this.datas.push({
message: `${this.datas.length}`
})
}
this.scheduleOnce(() => this.layout.total(this.datas.length), 1)
}
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "1.0.8",
"uuid": "57b8308f-b748-416b-b117-41f8cb429157",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

13
assets/scripts/simple.ts Normal file
View File

@@ -0,0 +1,13 @@
import BaseMain from './baseMain';
const { ccclass, property } = cc._decorator;
@ccclass
export default class Simple extends BaseMain {
async onLoad() {
for (let i = 0; i < 200; i++) {
this.datas.push({ message: i })
}
await this.layout.total(this.datas.length)
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "1.0.8",
"uuid": "48983ecd-03d8-4052-b424-6d41d9ce85ac",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}

View File

@@ -0,0 +1,19 @@
import BaseItem from './baseItem';
const { ccclass, property } = cc._decorator;
@ccclass
export default class Vertical extends BaseItem {
onLoad() {
this.input.placeholder = this.transform.height.toString()
}
onInput() {
let height = Number(this.input.string)
if (isNaN(height)) return
if (height < 100) {
return
}
this.transform.setContentSize(new cc.Size(this.transform.width, height))
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "1.0.8",
"uuid": "a33f01f3-a0ca-430d-87ba-9a95e13fedf1",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}