db55e556d5c6df39faa82b18d1d537fa5ac1c3a6.js 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. System.register(["__unresolved_0", "cc", "__unresolved_1"], function (_export, _context) {
  2. "use strict";
  3. var _reporterNs, _cclegacy, __checkObsolete__, __checkObsoleteInNamespace__, CCInteger, Component, _decorator, VMEnv, _dec, _dec2, _class, _class2, _descriptor, _descriptor2, _crd, ccclass, property, executeInEditMode, menu, BhvSwitchPage;
  4. function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); }
  5. function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
  6. function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
  7. function _reportPossibleCrUseOfVMEnv(extras) {
  8. _reporterNs.report("VMEnv", "../VMEnv", _context.meta, extras);
  9. }
  10. return {
  11. setters: [function (_unresolved_) {
  12. _reporterNs = _unresolved_;
  13. }, function (_cc) {
  14. _cclegacy = _cc.cclegacy;
  15. __checkObsolete__ = _cc.__checkObsolete__;
  16. __checkObsoleteInNamespace__ = _cc.__checkObsoleteInNamespace__;
  17. CCInteger = _cc.CCInteger;
  18. Component = _cc.Component;
  19. _decorator = _cc._decorator;
  20. }, function (_unresolved_2) {
  21. VMEnv = _unresolved_2.VMEnv;
  22. }],
  23. execute: function () {
  24. _crd = true;
  25. _cclegacy._RF.push({}, "b3d083kncpDPqVztMtiq6DO", "BhvSwitchPage", undefined);
  26. __checkObsolete__(['CCInteger', 'Component', 'Node', '_decorator']);
  27. ({
  28. ccclass,
  29. property,
  30. executeInEditMode,
  31. menu
  32. } = _decorator);
  33. /** 页面切换 */
  34. _export("BhvSwitchPage", BhvSwitchPage = (_dec = menu("OopsFramework/UI/Switch Page (页面切换)"), _dec2 = property({
  35. type: CCInteger
  36. }), ccclass(_class = executeInEditMode(_class = _dec(_class = (_class2 = class BhvSwitchPage extends Component {
  37. constructor() {
  38. super(...arguments);
  39. _initializerDefineProperty(this, "isLoopPage", _descriptor, this);
  40. _initializerDefineProperty(this, "_index", _descriptor2, this);
  41. this.preIndex = 0;
  42. //判断是否在 changing 页面状态
  43. this._isChanging = false;
  44. }
  45. get index() {
  46. return this._index;
  47. }
  48. set index(v) {
  49. if (this.isChanging) return;
  50. v = Math.round(v);
  51. var count = this.node.children.length - 1;
  52. if (this.isLoopPage) {
  53. if (v > count) v = 0;
  54. if (v < 0) v = count;
  55. } else {
  56. if (v > count) v = count;
  57. if (v < 0) v = 0;
  58. }
  59. this.preIndex = this._index; //标记之前的页面
  60. this._index = v;
  61. if ((_crd && VMEnv === void 0 ? (_reportPossibleCrUseOfVMEnv({
  62. error: Error()
  63. }), VMEnv) : VMEnv).editor) {
  64. this._updateEditorPage(v);
  65. } else {
  66. this._updatePage(v);
  67. }
  68. }
  69. /**只读,是否在changing 的状态 */
  70. get isChanging() {
  71. return this._isChanging;
  72. }
  73. onLoad() {
  74. this.preIndex = this.index;
  75. }
  76. _updateEditorPage(page) {
  77. if (!(_crd && VMEnv === void 0 ? (_reportPossibleCrUseOfVMEnv({
  78. error: Error()
  79. }), VMEnv) : VMEnv).editor) return;
  80. var children = this.node.children;
  81. for (var i = 0; i < children.length; i++) {
  82. var node = children[i];
  83. if (i == page) {
  84. node.active = true;
  85. } else {
  86. node.active = false;
  87. }
  88. }
  89. }
  90. _updatePage(page) {
  91. var children = this.node.children;
  92. var preIndex = this.preIndex;
  93. var curIndex = this.index;
  94. if (preIndex === curIndex) return; //没有改变就不进行操作
  95. var preNode = children[preIndex]; //旧节点
  96. var showNode = children[curIndex]; //新节点
  97. preNode.active = false;
  98. showNode.active = true;
  99. }
  100. next() {
  101. if (this.isChanging) {
  102. return false;
  103. } else {
  104. this.index++;
  105. return true;
  106. }
  107. }
  108. previous() {
  109. if (this.isChanging) {
  110. return false;
  111. } else {
  112. this.index--;
  113. return true;
  114. }
  115. }
  116. setEventIndex(e, index) {
  117. if (this.index >= 0 && this.index != null && this.isChanging === false) {
  118. this.index = index;
  119. return true;
  120. } else {
  121. return false;
  122. }
  123. }
  124. }, (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "isLoopPage", [property], {
  125. configurable: true,
  126. enumerable: true,
  127. writable: true,
  128. initializer: function initializer() {
  129. return false;
  130. }
  131. }), _descriptor2 = _applyDecoratedDescriptor(_class2.prototype, "_index", [property], {
  132. configurable: true,
  133. enumerable: true,
  134. writable: true,
  135. initializer: function initializer() {
  136. return 0;
  137. }
  138. }), _applyDecoratedDescriptor(_class2.prototype, "index", [_dec2], Object.getOwnPropertyDescriptor(_class2.prototype, "index"), _class2.prototype)), _class2)) || _class) || _class) || _class));
  139. _cclegacy._RF.pop();
  140. _crd = false;
  141. }
  142. };
  143. });
  144. //# sourceMappingURL=db55e556d5c6df39faa82b18d1d537fa5ac1c3a6.js.map