@netless/telebox-insider 0.3.0-beta.4 → 0.3.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -846,6 +846,8 @@ interface TeleBoxManager extends ValEnhancedResult<ValConfig> {
846
846
  declare class TeleBoxManager {
847
847
  private boxesStatus$;
848
848
  private lastNotMinimizedBoxesStatus$;
849
+ private effectBoxStatusTimer?;
850
+ private effectLastNotMinimizedBoxStatusTimer?;
849
851
  constructor({ root, prefersColorScheme, minimized, maximized, fence, containerRect, collector, namespace, readonly, }?: TeleBoxManagerConfig);
850
852
  get boxes(): ReadonlyArray<TeleBox>;
851
853
  get topBox(): TeleBox | undefined;
@@ -866,6 +868,7 @@ declare class TeleBoxManager {
866
868
  get boxesStatus(): ReadonlyMap<string, TeleBoxState>;
867
869
  get lastNotMinimizedBoxesStatus(): ReadonlyMap<string, NotMinimizedBoxState>;
868
870
  setBoxesStatus(boxesStatus: Map<string, TeleBoxState>, skipUpdate?: boolean): void;
871
+ private effectBoxStatusTimerFunc;
869
872
  private effectBoxStatusChange;
870
873
  hasBoxesStatus(): boolean;
871
874
  hasMinimizedBox(): boolean;
@@ -895,7 +898,6 @@ declare class TeleBoxManager {
895
898
  protected smartPosition(config?: TeleBoxConfig): TeleBoxConfig;
896
899
  protected makeBoxTop(box: TeleBox, skipUpdate?: boolean): void;
897
900
  protected makeMaximizedTopBoxFocus(): void;
898
- private makeTopBoxEffect;
899
901
  protected makeMaximizedBoxFocus(maximizedBox: MaxTitleBarTeleBox, skipUpdate?: boolean): void;
900
902
  protected makeMaximizedBoxBlur(): void;
901
903
  protected getBoxIndex(boxOrID: TeleBox | string): number;
@@ -2905,8 +2905,9 @@ class TeleBoxManager {
2905
2905
  this.boxesStatus$ = boxesStatus;
2906
2906
  this.effectBoxStatusChange(skipUpdate);
2907
2907
  }
2908
- effectBoxStatusChange(skipUpdate = false) {
2908
+ effectBoxStatusTimerFunc(skipUpdate) {
2909
2909
  var _a, _b, _c, _d;
2910
+ this.effectBoxStatusTimer = void 0;
2910
2911
  let topBox;
2911
2912
  const topBoxId = (_a = this.topBox) == null ? void 0 : _a.id;
2912
2913
  let hasMinimizedBox = false;
@@ -2939,6 +2940,28 @@ class TeleBoxManager {
2939
2940
  if (this.maxTitleBar) {
2940
2941
  this.maxTitleBar.updateBoxesStatus();
2941
2942
  }
2943
+ console.log("effectBoxStatusTimerFunc===>end", skipUpdate, this.boxes$.value.map((b) => ({ id: b.id, focus: b.focus, boxStatus: b.boxStatus, zIndex: b.zIndex })));
2944
+ }
2945
+ effectBoxStatusChange(skipUpdate = false) {
2946
+ var _a, _b;
2947
+ if (this.effectBoxStatusTimer && this.effectBoxStatusTimer.timer) {
2948
+ clearTimeout(this.effectBoxStatusTimer.timer);
2949
+ if (this.effectBoxStatusTimer.skipUpdate !== skipUpdate) {
2950
+ this.effectBoxStatusTimer.skipUpdate = skipUpdate;
2951
+ console.log("effectBoxStatusTimerFunc===>1111", skipUpdate);
2952
+ this.effectBoxStatusTimerFunc(this.effectBoxStatusTimer.skipUpdate);
2953
+ }
2954
+ }
2955
+ if (!this.effectBoxStatusTimer) {
2956
+ this.effectBoxStatusTimer = {
2957
+ skipUpdate,
2958
+ timer: void 0
2959
+ };
2960
+ }
2961
+ console.log("effectBoxStatusTimerFunc===>000", skipUpdate, { id: (_a = this.topBox$.value) == null ? void 0 : _a.id, zIndex: (_b = this.topBox$.value) == null ? void 0 : _b.zIndex }, this.boxes$.value.map((b) => ({ id: b.id, focus: b.focus, boxStatus: b.boxStatus, zIndex: b.zIndex })));
2962
+ this.effectBoxStatusTimer.timer = setTimeout(() => {
2963
+ this.effectBoxStatusTimerFunc(skipUpdate);
2964
+ }, 100);
2942
2965
  }
2943
2966
  hasBoxesStatus() {
2944
2967
  return this.boxesStatus$.size > 0;
@@ -3296,10 +3319,25 @@ class TeleBoxManager {
3296
3319
  makeBoxTop(box, skipUpdate = false) {
3297
3320
  if (this.topBox) {
3298
3321
  if (box !== this.topBox) {
3299
- const currentBoxZIndex = box.zIndex;
3300
- const addZIndex = this.topBox.zIndex + 1 - box.zIndex;
3301
- box.setZIndex(this.topBox.zIndex + 1, skipUpdate);
3302
- this.makeTopBoxEffect(box.id, addZIndex, currentBoxZIndex, skipUpdate);
3322
+ if (!this.hasBoxesStatus()) {
3323
+ box.setZIndex(this.topBox.zIndex + 1, skipUpdate);
3324
+ return;
3325
+ }
3326
+ const maxZIndex = this.boxes.reduce((maxZIndex2, box2) => {
3327
+ return Math.max(maxZIndex2, box2.zIndex);
3328
+ }, 0);
3329
+ const currentTopBoxZIndex = Math.min(this.topBox.zIndex, box.zIndex);
3330
+ const addZIndex = maxZIndex + 1 - currentTopBoxZIndex;
3331
+ box.setZIndex(maxZIndex + 1, skipUpdate);
3332
+ console.log("makeBoxTop===>", box.id, maxZIndex + 1, addZIndex, this.topBox.id, currentTopBoxZIndex);
3333
+ if (box.boxStatus !== exports.TELE_BOX_STATE.Minimized) {
3334
+ this.boxes.forEach((b) => {
3335
+ if (b.boxStatus === exports.TELE_BOX_STATE.Minimized && b.zIndex >= currentTopBoxZIndex) {
3336
+ console.log("makeBoxTop===>111", b.id, b.zIndex + addZIndex);
3337
+ b.setZIndex(b.zIndex + addZIndex, skipUpdate);
3338
+ }
3339
+ });
3340
+ }
3303
3341
  }
3304
3342
  }
3305
3343
  }
@@ -3317,15 +3355,6 @@ class TeleBoxManager {
3317
3355
  }
3318
3356
  }
3319
3357
  }
3320
- makeTopBoxEffect(boxId, addZIndex, currentZIndex, skipUpdate = false) {
3321
- if (this.hasBoxesStatus() && this.hasMinimizedBox()) {
3322
- this.boxes.forEach((b) => {
3323
- if (b.boxStatus && b.id !== boxId && b.zIndex >= currentZIndex) {
3324
- b.setZIndex(b.zIndex + addZIndex, skipUpdate);
3325
- }
3326
- });
3327
- }
3328
- }
3329
3358
  makeMaximizedBoxFocus(maximizedBox, skipUpdate = false) {
3330
3359
  if (this.maxTitleBar.hasMaximizedBoxInStatus() && this.maxTitleBar.MaximizedBoxes.find((box) => box.id === maximizedBox.id)) {
3331
3360
  const currentZIndex = maximizedBox.zIndex;