@latest-thinking/lt-player 1.0.5-a → 1.0.5-c

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": "@latest-thinking/lt-player",
3
- "version": "1.0.5-a",
3
+ "version": "1.0.5-c",
4
4
  "description": "LT player.",
5
5
  "main": "dist/js/lt-player-main.js",
6
6
  "module": "dist/js/lt-player-main.js",
@@ -30,7 +30,7 @@
30
30
  align-items: end;
31
31
  display: flex;
32
32
  flex-direction: column;
33
- justify-content: end;
33
+ justify-content: flex-end;
34
34
  gap: 2rem;
35
35
  background: transparent;
36
36
  padding-bottom: 1.6rem;
@@ -47,7 +47,7 @@
47
47
  align-items: end;
48
48
  display: flex;
49
49
  flex-direction: column;
50
- justify-content: end;
50
+ justify-content: flex-end;
51
51
  gap: 1rem;
52
52
  background: transparent;
53
53
  padding-bottom: 1rem;
@@ -46,11 +46,11 @@
46
46
  }
47
47
 
48
48
  &__previous-chapter-view {
49
- justify-content: end;
49
+ justify-content: flex-end;
50
50
  }
51
51
 
52
52
  &__next-chapter-view {
53
- justify-content: start;
53
+ justify-content: flex-start;
54
54
  }
55
55
 
56
56
  &__next-chapter-view,
@@ -4,30 +4,11 @@
4
4
  height: 100%;
5
5
  }
6
6
 
7
- @media (min-width: 266px) {
8
- .lt-player-mini-player-observe {
9
- height: 150px;
10
- }
11
- }
12
- @media (min-width: 533px) {
13
- .lt-player-mini-player-observe {
14
- height: 200px;
15
- }
7
+ .lt-player-mini-player-observe {
8
+ min-height: 200px;
9
+ max-height: 600px;
10
+ height: auto;
16
11
  }
17
- @media (min-width: 800px) {
18
- .lt-player-mini-player-observe {
19
- height: 400px;
20
- }
21
- }
22
- @media (min-width: 1067px) {
23
- .lt-player-mini-player-observe {
24
- height: 600px;
25
- }
26
- }
27
-
28
-
29
-
30
-
31
12
 
32
13
  .lt-player-mini-enable {
33
14
  position: fixed;
@@ -21,6 +21,8 @@ export class LTPlayerMini {
21
21
 
22
22
  instance : LTPlayer.PortraitType | LTPlayer.LandscapeType
23
23
 
24
+ observe : ResizeObserver
25
+
24
26
  constructor() {
25
27
  }
26
28
 
@@ -63,14 +65,13 @@ export class LTPlayerMini {
63
65
  player.on('ready', function () {
64
66
  const playerContainer = player.elements.container;
65
67
  const playerWrapper = player.elements.wrapper;
66
- _this.playerContainer.width = playerWrapper.getBoundingClientRect().width;
67
- _this.playerContainer.height = playerWrapper.getBoundingClientRect().height;
68
-
69
68
  const button = playerContainer.querySelector('.mini-player-control');
70
69
 
71
70
  if (button) {
72
71
  button.addEventListener('click', function (event) {
73
72
  event.preventDefault();
73
+ _this.playerContainer.width = playerContainer.getBoundingClientRect().width;
74
+ _this.playerContainer.height = playerContainer.getBoundingClientRect().height;
74
75
  playerWrapper.classList.add('lt-player-mini-enable');
75
76
  playerWrapper.classList.add(`lt-player-mini-${_this.playerType}`)
76
77
  _this.setBackground(playerWrapper);
@@ -118,17 +119,7 @@ export class LTPlayerMini {
118
119
  */
119
120
  private setBackground(playerWrapper: HTMLElement) {
120
121
 
121
- let classObserve = false;
122
-
123
- if (this.instance.playerConfig.getObserve()) {
124
- if (this.instance.playerConfig.isObserveHeight() !== undefined && !this.instance.playerConfig.isObserveHeight()) {
125
- classObserve = true;
126
- }
127
- } else {
128
- classObserve = true
129
- }
130
-
131
- const background = this.templateService.getBackGroundTemplate({logo : this.iconService.getLogo(), classObserve : (classObserve) ? 'lt-player-mini-player-observe' : ""});
122
+ const background = this.templateService.getBackGroundTemplate({logo : this.iconService.getLogo()});
132
123
 
133
124
  const controls = this.templateService.getControlsMiniPlayer({
134
125
  mini_player: 'true',
@@ -137,12 +128,48 @@ export class LTPlayerMini {
137
128
 
138
129
  playerWrapper.insertAdjacentHTML("afterend", background);
139
130
  playerWrapper.children[0].insertAdjacentHTML("afterend", controls);
140
- }
141
131
 
132
+ if (this.instance.playerConfig.getObserve()) {
133
+ if (this.instance.playerConfig.isObserveHeight() !== undefined && !this.instance.playerConfig.isObserveHeight()) {
134
+ this.setObserveBackground();
135
+ }
136
+ } else {
137
+ this.setObserveBackground();
138
+ }
139
+
140
+ }
142
141
 
142
+ setObserveBackground() {
143
+
144
+ const miniPlayerBackground : HTMLElement = this.player.elements.container.querySelector('.lt-player-mini-player-background');
145
+
146
+ this.observe = new ResizeObserver(response => {
147
+ let documentWidth = response[0].contentRect.width;
148
+ let miniPlayerBackgroundWidth = miniPlayerBackground.getBoundingClientRect().width;
149
+ if (documentWidth >= miniPlayerBackgroundWidth) {
150
+ if (documentWidth > this.playerContainer.width) {
151
+ if (this.player.elements.controls.getBoundingClientRect().height === 103) {
152
+ miniPlayerBackground.style.width = `${this.playerContainer.width}px`;
153
+ miniPlayerBackground.style.height = `${this.playerContainer.height}px`;
154
+ } else {
155
+ miniPlayerBackground.style.width = `${this.player.elements.controls.getBoundingClientRect().width}px`;
156
+ miniPlayerBackground.style.height = `${this.player.elements.controls.getBoundingClientRect().height}px`;
157
+ }
158
+ } else {
159
+ miniPlayerBackground.style.width = `${this.playerContainer.width}px`;
160
+ let calc = this.playerContainer.height + (response[0].contentRect.width - this.playerContainer.width);
161
+ miniPlayerBackground.style.height = (calc > 100) ? `${calc}px` : this.playerContainer.height;
162
+ }
163
+ }
164
+ if (documentWidth < miniPlayerBackgroundWidth) {
165
+ miniPlayerBackground.style.width = `${documentWidth}px`;
166
+ let calc = this.playerContainer.height - (this.playerContainer.width - response[0].contentRect.width);
167
+ miniPlayerBackground.style.height = (calc > 100) ? `${calc}px` : this.playerContainer.height;
168
+ }
143
169
 
144
- test() {
170
+ });
145
171
 
172
+ this.observe.observe(document.body);
146
173
  }
147
174
 
148
175
  /**
@@ -229,6 +256,7 @@ export class LTPlayerMini {
229
256
  playerContainer.querySelector('.lt-player-mini-player-background').remove();
230
257
  playerContainer.querySelector('.lt-player-mini-enable').classList.remove(`lt-player-mini-${_this.playerType}`)
231
258
  playerContainer.querySelector('.lt-player-mini-enable').classList.remove('lt-player-mini-enable');
259
+ _this.observe.disconnect();
232
260
 
233
261
  })
234
262
  }