
cc.Class({
    extends: cc.Component,

    properties: {

    	listBlock: {
    		type: cc.Node,
    		default: null	
    	},

        myList: {
            type: cc.Node,
            default: null
        },

        listController: {
            type: cc.ScrollView,
            default: null
        }
    },

    // LIFE-CYCLE CALLBACKS:

    onLoad () {

        F.common.initNodePool(this, F.prefab.rankListBlock);
        this.loadList();
        this.loadMySelf();
        // F.common.initNodePool(this, F.prefab.test);
        // this.loadTest();
    },



    genTestBlock (parent) {
        let poolName = F.prefab.test.name + "Pool";
        let pool = this[poolName];
        let newNode = F.common.genNewNode(pool, F.prefab.test.prefab, parent);
        return newNode;
    },

    loadList () {
        let poolName = F.prefab.rankListBlock.name + "Pool";
        let pool = this[poolName];
        for (let i = 0; i < 100; i++) {
            let tempBlock = this.genListBlock(this.listBlock);
            if (i == 0) {
                tempBlock.getComponent("listBlock").first();
            }else {
                tempBlock.getComponent("listBlock").setNumber(i+1);
            }
        }
        // console.log(this.listController)
        let self = this;
        // this.scheduleOnce(()=>{
        //     self.listController.scrollToTop(0);

        // }, 0.01);
    },

    genListBlock (parent) {
        let poolName = F.prefab.rankListBlock.name + "Pool";
        let pool = this[poolName];
        let newNode = F.common.genNewNode(pool, F.prefab.rankListBlock.prefab, parent);
        return newNode;
    },

    loadMySelf () {
        let myList = this.genListBlock(this.myList);
        myList.getComponent("listBlock").setNumber("100+");

    },

    start () {
        this.listController.scrollToTop(0)
    },

    // update (dt) {},
});
