@netless/telebox-insider 1.0.0-alpha.6 → 1.0.0-alpha.9

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": "1.0.0-alpha.6",
3
+ "version": "1.0.0-alpha.9",
4
4
  "private": false,
5
5
  "description": "Window widget for Whiteboard",
6
6
  "license": "MIT",
@@ -63,6 +63,6 @@
63
63
  "shallowequal": "^1.1.0",
64
64
  "side-effect-manager": "^1.1.0",
65
65
  "stylefire": "^7.0.3",
66
- "value-enhancer": "^1.2.1"
66
+ "value-enhancer": "^1.3.0"
67
67
  }
68
68
  }
@@ -719,40 +719,39 @@ export class TeleBox {
719
719
  pxIntrinsicCoord,
720
720
  collectorRect,
721
721
  ]) => {
722
+ const styles = maximized
723
+ ? {
724
+ x: 0,
725
+ y: 0,
726
+ width: "100%",
727
+ height: "100%",
728
+ scaleX: 1,
729
+ scaleY: 1,
730
+ }
731
+ : {
732
+ x: pxIntrinsicCoord.x,
733
+ y: pxIntrinsicCoord.y,
734
+ width: pxIntrinsicSize.width + "px",
735
+ height: pxIntrinsicSize.height + "px",
736
+ scaleX: 1,
737
+ scaleY: 1,
738
+ };
722
739
  if (minimized && collectorRect) {
723
- return {
724
- x:
725
- collectorRect.x -
726
- pxIntrinsicSize.width / 2 +
727
- collectorRect.width / 2,
728
- y:
729
- collectorRect.y -
730
- pxIntrinsicSize.height / 2 +
731
- collectorRect.height / 2,
732
- width: pxIntrinsicSize.width + "px",
733
- height: pxIntrinsicSize.height + "px",
734
- scaleX: collectorRect.width / pxIntrinsicSize.width,
735
- scaleY: collectorRect.height / pxIntrinsicSize.height,
736
- };
737
- }
738
- if (maximized) {
739
- return {
740
- x: 0,
741
- y: 0,
742
- width: "100%",
743
- height: "100%",
744
- scaleX: 1,
745
- scaleY: 1,
746
- };
740
+ const { width: boxWidth, height: boxHeight } = maximized
741
+ ? this.rootRect
742
+ : pxIntrinsicSize;
743
+ styles.x =
744
+ collectorRect.x -
745
+ boxWidth / 2 +
746
+ collectorRect.width / 2;
747
+ styles.y =
748
+ collectorRect.y -
749
+ boxHeight / 2 +
750
+ collectorRect.height / 2;
751
+ styles.scaleX = collectorRect.width / boxWidth;
752
+ styles.scaleY = collectorRect.height / boxHeight;
747
753
  }
748
- return {
749
- x: pxIntrinsicCoord.x,
750
- y: pxIntrinsicCoord.y,
751
- width: pxIntrinsicSize.width + "px",
752
- height: pxIntrinsicSize.height + "px",
753
- scaleX: 1,
754
- scaleY: 1,
755
- };
754
+ return styles;
756
755
  },
757
756
  { compare: shallowequal }
758
757
  );
@@ -790,16 +789,14 @@ export class TeleBox {
790
789
  this.$content = $content;
791
790
 
792
791
  this._sideEffect.add(() => {
793
- const observer = new ResizeObserver((entries) => {
794
- const rect = entries[0]?.contentRect;
795
- if (rect) {
796
- this._contentRect$.setValue({
797
- x: rect.x,
798
- y: rect.y,
799
- width: rect.width,
800
- height: rect.height,
801
- });
802
- }
792
+ const observer = new ResizeObserver(() => {
793
+ const rect = $content.getBoundingClientRect();
794
+ this._contentRect$.setValue({
795
+ x: rect.x,
796
+ y: rect.y,
797
+ width: rect.width,
798
+ height: rect.height,
799
+ });
803
800
  });
804
801
  observer.observe($content);
805
802
  return () => observer.disconnect();
@@ -75,11 +75,6 @@ export class MaxTitleBar extends DefaultTitleBar {
75
75
 
76
76
  this.sideEffect.addDisposer(
77
77
  [
78
- this.rootRect$.subscribe((rootRect) => {
79
- const { x, y, width } = rootRect;
80
- $titleBar.style.transform = `translate(${x}px, ${y}px)`;
81
- $titleBar.style.width = width + "px";
82
- }),
83
78
  this.state$.subscribe((state) => {
84
79
  $titleBar.classList.toggle(
85
80
  this.wrapClassName("max-titlebar-maximized"),
@@ -16,7 +16,10 @@ $scrollbar-color-active: rgba(238, 238, 247, 1);
16
16
  position: absolute;
17
17
  top: 0;
18
18
  left: 0;
19
- z-index: $base-z-index * 500;
19
+ width: 100%;
20
+ z-index: $max-titlebar-z-index;
21
+ border-top-left-radius: 6px;
22
+ border-top-right-radius: 6px;
20
23
 
21
24
  .#{$namespace}-title {
22
25
  display: none;
@@ -95,7 +98,7 @@ $scrollbar-color-active: rgba(238, 238, 247, 1);
95
98
  height: 100%;
96
99
  overflow: hidden;
97
100
  max-width: 182px;
98
- min-width: 50px;
101
+ min-width: 150px;
99
102
  padding: 0 26px 0 16px;
100
103
  outline: none;
101
104
  font-size: 13px;
@@ -111,16 +111,14 @@ export class TeleBoxManager {
111
111
  if (!root) {
112
112
  return () => void 0;
113
113
  }
114
- const observer = new ResizeObserver((entries) => {
115
- const rect = entries[0]?.contentRect;
116
- if (rect) {
117
- rootRect$.setValue({
118
- x: rect.x,
119
- y: rect.y,
120
- width: rect.width,
121
- height: rect.height,
122
- });
123
- }
114
+ const observer = new ResizeObserver(() => {
115
+ const rect = root.getBoundingClientRect();
116
+ rootRect$.setValue({
117
+ x: rect.x,
118
+ y: rect.y,
119
+ width: rect.width,
120
+ height: rect.height,
121
+ });
124
122
  });
125
123
  observer.observe(root);
126
124
  return () => observer.disconnect();
@@ -206,8 +204,9 @@ export class TeleBoxManager {
206
204
  ratio$: stageRatio$,
207
205
  root$,
208
206
  highlightStage$: combine(
209
- [highlightStage$, maximized$],
210
- ([highlightStage, maximized]) => highlightStage && !maximized
207
+ [highlightStage$, maximized$, minimized$],
208
+ ([highlightStage, maximized, minimized]) =>
209
+ highlightStage && (minimized || !maximized)
211
210
  ),
212
211
  });
213
212
  this._sideEffect.addDisposer(() => teleStage.destroy());
@@ -1,4 +1,5 @@
1
1
  $namespace: "telebox";
2
2
  $base-z-index: 100;
3
- $stage-z-index: $base-z-index + 2000;
4
- $collector-z-index: $stage-z-index + 1;
3
+ $max-titlebar-z-index: $base-z-index + 5000;
4
+ $stage-z-index: $max-titlebar-z-index + 10;
5
+ $collector-z-index: $stage-z-index + 10;