@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netless/telebox-insider",
3
- "version": "0.3.0-beta.4",
3
+ "version": "0.3.0-beta.5",
4
4
  "private": false,
5
5
  "description": "Window widget for Whiteboard",
6
6
  "author": "CRIMX <straybugs@gmail.com> (https://github.com/crimx/)",
@@ -49,6 +49,14 @@ export interface TeleBoxManager extends ValEnhancedResult<ValConfig> {}
49
49
  export class TeleBoxManager {
50
50
  private boxesStatus$: Map<string, TeleBoxState>;
51
51
  private lastNotMinimizedBoxesStatus$: Map<string, NotMinimizedBoxState>;
52
+ private effectBoxStatusTimer?: {
53
+ skipUpdate: boolean;
54
+ timer: number | undefined;
55
+ }
56
+ private effectLastNotMinimizedBoxStatusTimer?: {
57
+ skipUpdate: boolean;
58
+ timer: number | undefined;
59
+ }
52
60
 
53
61
  public constructor({
54
62
  root = document.body,
@@ -479,7 +487,9 @@ export class TeleBoxManager {
479
487
  this.effectBoxStatusChange(skipUpdate);
480
488
  }
481
489
 
482
- private effectBoxStatusChange(skipUpdate = false){
490
+
491
+ private effectBoxStatusTimerFunc(skipUpdate: boolean){
492
+ this.effectBoxStatusTimer = undefined;
483
493
  let topBox:TeleBox | undefined;
484
494
  const topBoxId = this.topBox?.id;
485
495
  let hasMinimizedBox = false;
@@ -513,6 +523,31 @@ export class TeleBoxManager {
513
523
  if (this.maxTitleBar) {
514
524
  this.maxTitleBar.updateBoxesStatus();
515
525
  }
526
+ console.log("effectBoxStatusTimerFunc===>end", skipUpdate, this.boxes$.value.map((b)=>({id:b.id,focus:b.focus, boxStatus:b.boxStatus,zIndex:b.zIndex})));
527
+ }
528
+
529
+ private effectBoxStatusChange(skipUpdate = false){
530
+ if (this.effectBoxStatusTimer && this.effectBoxStatusTimer.timer) {
531
+ clearTimeout(this.effectBoxStatusTimer.timer);
532
+ if (this.effectBoxStatusTimer.skipUpdate !== skipUpdate) {
533
+ this.effectBoxStatusTimer.skipUpdate = skipUpdate;
534
+ console.log("effectBoxStatusTimerFunc===>1111", skipUpdate);
535
+ this.effectBoxStatusTimerFunc(this.effectBoxStatusTimer.skipUpdate)
536
+ }
537
+ }
538
+ if (!this.effectBoxStatusTimer) {
539
+ this.effectBoxStatusTimer = {
540
+ skipUpdate,
541
+ timer: undefined,
542
+ } as {
543
+ skipUpdate: boolean;
544
+ timer: number | undefined;
545
+ }
546
+ }
547
+ console.log("effectBoxStatusTimerFunc===>000", skipUpdate, {id:this.topBox$.value?.id, zIndex:this.topBox$.value?.zIndex}, this.boxes$.value.map((b)=>({id:b.id,focus:b.focus, boxStatus:b.boxStatus,zIndex:b.zIndex})));
548
+ this.effectBoxStatusTimer.timer = setTimeout(()=>{
549
+ this.effectBoxStatusTimerFunc(skipUpdate)
550
+ }, 100) as unknown as number;
516
551
  }
517
552
 
518
553
  public hasBoxesStatus(): boolean {
@@ -961,10 +996,25 @@ export class TeleBoxManager {
961
996
  protected makeBoxTop(box: TeleBox, skipUpdate = false): void {
962
997
  if (this.topBox) {
963
998
  if (box !== this.topBox) {
964
- const currentBoxZIndex = box.zIndex;
965
- const addZIndex = this.topBox.zIndex + 1 - box.zIndex;
966
- box.setZIndex(this.topBox.zIndex + 1, skipUpdate);
967
- this.makeTopBoxEffect(box.id, addZIndex, currentBoxZIndex, skipUpdate);
999
+ if (!this.hasBoxesStatus()) {
1000
+ box.setZIndex(this.topBox.zIndex + 1, skipUpdate);
1001
+ return;
1002
+ }
1003
+ const maxZIndex = this.boxes.reduce((maxZIndex, box) => {
1004
+ return Math.max(maxZIndex, box.zIndex);
1005
+ }, 0);
1006
+ const currentTopBoxZIndex = Math.min(this.topBox.zIndex, box.zIndex);
1007
+ const addZIndex = maxZIndex + 1 - currentTopBoxZIndex;
1008
+ box.setZIndex(maxZIndex + 1, skipUpdate);
1009
+ console.log("makeBoxTop===>", box.id, maxZIndex + 1, addZIndex, this.topBox.id, currentTopBoxZIndex);
1010
+ if (box.boxStatus !== TELE_BOX_STATE.Minimized) {
1011
+ this.boxes.forEach((b) => {
1012
+ if (b.boxStatus === TELE_BOX_STATE.Minimized && b.zIndex >= currentTopBoxZIndex) {
1013
+ console.log("makeBoxTop===>111", b.id, b.zIndex + addZIndex);
1014
+ b.setZIndex(b.zIndex + addZIndex, skipUpdate);
1015
+ }
1016
+ });
1017
+ }
968
1018
  }
969
1019
  }
970
1020
  }
@@ -984,16 +1034,6 @@ export class TeleBoxManager {
984
1034
  }
985
1035
  }
986
1036
 
987
- private makeTopBoxEffect(boxId: string, addZIndex: number, currentZIndex: number, skipUpdate = false): void {
988
- if (this.hasBoxesStatus() && this.hasMinimizedBox()) {
989
- this.boxes.forEach((b) => {
990
- if (b.boxStatus && b.id !== boxId && b.zIndex >= currentZIndex) {
991
- b.setZIndex(b.zIndex + addZIndex, skipUpdate);
992
- }
993
- });
994
- }
995
- }
996
-
997
1037
  protected makeMaximizedBoxFocus(maximizedBox: MaxTitleBarTeleBox, skipUpdate = false): void {
998
1038
  if (this.maxTitleBar.hasMaximizedBoxInStatus() && this.maxTitleBar.MaximizedBoxes.find((box) => box.id === maximizedBox.id)) {
999
1039
  const currentZIndex = maximizedBox.zIndex;