ZoomBtn.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. var t = require;
  2. var e = module;
  3. var i = exports;
  4. var s =
  5. (this && this.__decorate) ||
  6. function(t, e, i, s) {
  7. var o,
  8. a = arguments.length,
  9. n = a < 3 ? e : null === s ? (s = Object.getOwnPropertyDescriptor(e, i)) : s;
  10. if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) n = Reflect.decorate(t, e, i, s);
  11. else
  12. for (var r = t.length - 1; 0 <= r; r--)
  13. (o = t[r]) && (n = (a < 3 ? o(n) : 3 < a ? o(e, i, n) : o(e, i)) || n);
  14. return 3 < a && n && Object.defineProperty(e, i, n), n;
  15. };
  16. Object.defineProperty(i, "__esModule", { value: !0 });
  17. const { ccclass: o, property: a, menu: n, executeInEditMode: r, playOnFocus: l } = cc._decorator;
  18. e = class extends cc.Component {
  19. constructor() {
  20. super(...arguments),
  21. (this._isShow = !0),
  22. (this._btns = []),
  23. (this._bgMinHeight = 100),
  24. (this._bgHeight = 0),
  25. (this.contractionBtn = null),
  26. (this.bgNode = null);
  27. }
  28. set isShow(t) {
  29. this.buttonChange();
  30. }
  31. get isShow() {
  32. return this._isShow;
  33. }
  34. set btns(t) {
  35. (this._btns = t), this.onChildChange();
  36. }
  37. get btns() {
  38. return this._btns;
  39. }
  40. onLoad() {}
  41. onChildChange() {
  42. var e = this._btns.length;
  43. this._bgHeight = this._bgMinHeight;
  44. let i = -64;
  45. for (let t = 0; t < e && this._btns[t]; t++)
  46. (this._bgHeight += 10 + this._btns[t].height),
  47. (this._btns[t].y = i),
  48. (this._btns[t].active = !0),
  49. (i -= 10 + this._btns[t].height);
  50. (this._isShow = !0), (this.contractionBtn.node.y = 40 - this._bgHeight), (this.bgNode.height = this._bgHeight);
  51. }
  52. buttonChange() {
  53. if (((this.contractionBtn.interactable = !1), (this._isShow = !this._isShow), this._isShow)) {
  54. cc.tween(this.bgNode).to(0.2, { height: this._bgHeight }).start(),
  55. cc
  56. .tween(this.contractionBtn.node)
  57. .to(0.2, { angle: 180, y: 40 - this._bgHeight })
  58. .start();
  59. let i = e => {
  60. if (e > this.btns.length - 1) this.contractionBtn.interactable = !0;
  61. else {
  62. let t = this.btns[e];
  63. (t.active = !0),
  64. cc
  65. .tween(t)
  66. .to(0.1, { y: t.y - t.height, opacity: 255 }, { easing: cc.easing.sineOut })
  67. .call(() => {
  68. i(++e);
  69. })
  70. .start();
  71. }
  72. };
  73. i(0);
  74. } else {
  75. cc
  76. .tween(this.contractionBtn.node)
  77. .to(0.2, { angle: 0, y: 40 - this._bgMinHeight })
  78. .start(),
  79. cc.tween(this.bgNode).to(0.2, { height: this._bgMinHeight }).start();
  80. let i = e => {
  81. if (e < 0) this.contractionBtn.interactable = !0;
  82. else {
  83. let t = this.btns[e];
  84. cc.tween(t)
  85. .to(0.1, { y: t.y + t.height, opacity: 0 }, { easing: cc.easing.sineOut })
  86. .call(() => {
  87. i(--e), (t.active = !1);
  88. })
  89. .start();
  90. }
  91. };
  92. i(this.btns.length - 1);
  93. }
  94. }
  95. };
  96. s([a], e.prototype, "_isShow", void 0),
  97. s([a({})], e.prototype, "isShow", null),
  98. s([a()], e.prototype, "_btns", void 0),
  99. s([a({ type: cc.Node })], e.prototype, "btns", null),
  100. s([a], e.prototype, "_bgMinHeight", void 0),
  101. s([a], e.prototype, "_bgHeight", void 0),
  102. s([a({ type: cc.Button })], e.prototype, "contractionBtn", void 0),
  103. s([a({ type: cc.Node })], e.prototype, "bgNode", void 0),
  104. (e = s([o, r, l], e)),
  105. (i.default = e);