const { regClass, property } = Laya

@regClass()
export class Script extends Laya.Script {
  @property(Laya.Label)
  public title: Laya.Label

  @property(Laya.Image)
  public icon: Laya.Image

  @property(Laya.Box)
  public obj_eases: Laya.Box

  onAwake(): void {
    const list: Array<any> = []
    list.push(Laya.Ease.backIn)
    list.push(Laya.Ease.backInOut)
    list.push(Laya.Ease.backOut)

    list.push(Laya.Ease.bounceIn)
    list.push(Laya.Ease.bounceInOut)
    list.push(Laya.Ease.bounceOut)

    list.push(Laya.Ease.circIn)
    list.push(Laya.Ease.circInOut)
    list.push(Laya.Ease.circOut)

    list.push(Laya.Ease.cubicIn)
    list.push(Laya.Ease.cubicInOut)
    list.push(Laya.Ease.cubicOut)

    list.push(Laya.Ease.elasticIn)
    list.push(Laya.Ease.elasticInOut)
    list.push(Laya.Ease.elasticOut)

    list.push(Laya.Ease.expoIn)
    list.push(Laya.Ease.expoInOut)
    list.push(Laya.Ease.expoOut)

    list.push(Laya.Ease.linearIn)
    list.push(Laya.Ease.linearInOut)
    list.push(Laya.Ease.linearNone)
    list.push(Laya.Ease.linearOut)

    list.push(Laya.Ease.quadIn)
    list.push(Laya.Ease.quadInOut)
    list.push(Laya.Ease.quadOut)

    list.push(Laya.Ease.quartIn)
    list.push(Laya.Ease.quartInOut)
    list.push(Laya.Ease.quartOut)

    list.push(Laya.Ease.quintIn)
    list.push(Laya.Ease.quintInOut)
    list.push(Laya.Ease.quintOut)

    list.push(Laya.Ease.sineIn)
    list.push(Laya.Ease.sineInOut)
    list.push(Laya.Ease.sineOut)

    list.push(Laya.Ease.strongIn)
    list.push(Laya.Ease.strongInOut)
    list.push(Laya.Ease.strongOut)
    console.log("length", list.length)

    this.title.text = ""

    for (let i = 0; i < list.length; i++) {
      const label = this.obj_eases.getChildAt(i) as Laya.Label
      label.text = list[i].name
      label.on(Laya.Event.CLICK, this, (evt: Laya.Event) => {
        const label = evt.target as Laya.Label
        this.title.text = label.text
        this.icon.x = 400
        for (let j = 0; j < list.length; j++) {
          const obj = list[j]
          if (obj.name === label.text) {
            Laya.Tween.to(this.icon, { x: 1500 }, 2000, obj)
            break
          }
        }
      })
    }
  }
}
