
const DWTool = require("../utils/DWTool");

cc.Class({
    extends: cc.Component,

    properties: {

        content: cc.Node,

        scrollView: cc.ScrollView,
    },

    // LIFE-CYCLE CALLBACKS:

    onLoad () {


        this.layout();

    },

    start() {

        this.content.y = -cc.view.getVisibleSize().height;

        this.scheduleOnce(() => {
            let s = cc.sequence(cc.moveTo(0.2, 0, -40).easing(cc.easeCubicActionOut()), cc.moveBy(0.05, 0, -20));
            this.content.runAction(s);
        }, 0.1);
    },


    layout() {

        DWTool.loadResPrefab('./prefabs/artist_resident_item')
        .then((result) => {
            
            for (let i = 0; i < 20; i++) {
                let item = cc.instantiate(result);
                this.scrollView.content.addChild(item);
            }
        
        }).catch((err) => {
            cc.error(err);
        });
    },

    close() {
        this.node.destroy();
    },

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