Skip to content

Commit a33054a

Browse files
committed
perf: modify guacamole player css
1 parent 3995f9a commit a33054a

File tree

4 files changed

+172
-6
lines changed

4 files changed

+172
-6
lines changed

src/app/elements/replay/guacamole/guacamole.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<button type="button" class="btn" (click)="restart()">
77
<i class="fa fa-repeat" aria-hidden="true"></i>
88
</button>
9-
<input id="position-slider" type="range" [(ngModel)]="percent" [attr.max]="max" (mouseup)="runFrom()">
9+
<span [ngClass]="rangeHideClass" style="width: 100%"><input id="position-slider" type="range" [(ngModel)]="percent" [attr.max]="max" (mouseup)="runFrom()"></span>
1010
<span id="position">{{ position }}</span>
1111
<span>/</span>
1212
<span id="duration">{{ duration }}</span>

src/app/elements/replay/guacamole/guacamole.component.scss

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,3 +149,140 @@
149149
#player .controls #duration {
150150
margin-right: 0;
151151
}
152+
153+
input[type="range"] {
154+
background: transparent;
155+
width: 100%;
156+
margin: 0;
157+
}
158+
159+
input[type="range"]:focus {
160+
outline: none;
161+
}
162+
163+
/*
164+
* WebKit
165+
*/
166+
167+
input[type="range"] {
168+
-webkit-appearance: none;
169+
}
170+
171+
input[type="range"]::-webkit-slider-runnable-track {
172+
173+
border: none;
174+
border-radius: 0;
175+
background: #5AF;
176+
177+
width: 100%;
178+
height: 0.5em;
179+
180+
cursor: pointer;
181+
182+
}
183+
184+
input[type="range"]::-webkit-slider-thumb {
185+
186+
border: none;
187+
border-radius: 0;
188+
background: white;
189+
//background: #5AF;
190+
191+
width: 3px;
192+
height: 0.5em;
193+
194+
-webkit-appearance: none;
195+
cursor: pointer;
196+
197+
}
198+
199+
input[type="range"]:focus::-webkit-slider-runnable-track {
200+
background: #5AF;
201+
}
202+
203+
/*
204+
* Firefox
205+
*/
206+
207+
input[type="range"]::-moz-range-track {
208+
209+
border: none;
210+
border-radius: 0;
211+
background: #5AF;
212+
213+
width: 100%;
214+
height: 0.5em;
215+
216+
cursor: pointer;
217+
218+
}
219+
220+
input[type="range"]::-moz-range-thumb {
221+
222+
border: none;
223+
border-radius: 0;
224+
background: white;
225+
226+
width: 3px;
227+
height: 0.5em;
228+
229+
cursor: pointer;
230+
231+
}
232+
233+
/*
234+
* Internet Explorer
235+
*/
236+
237+
input[type="range"]::-ms-track {
238+
239+
width: 100%;
240+
height: 0.5em;
241+
margin: 0;
242+
243+
border: none;
244+
border-radius: 0;
245+
background: transparent;
246+
color: transparent;
247+
248+
cursor: pointer;
249+
250+
}
251+
252+
input[type="range"]::-ms-thumb {
253+
254+
border: none;
255+
border-radius: 0;
256+
background: white;
257+
258+
width: 3px;
259+
height: 0.5em;
260+
margin: 0;
261+
262+
cursor: pointer;
263+
264+
}
265+
266+
input[type="range"]::-ms-fill-lower,
267+
input[type="range"]::-ms-fill-upper,
268+
input[type="range"]:focus::-ms-fill-lower,
269+
input[type="range"]:focus::-ms-fill-upper {
270+
border: none;
271+
border-radius: 0;
272+
background: #5AF;
273+
}
274+
275+
.hideCursor {
276+
input[type="range"]::-webkit-slider-thumb {
277+
278+
background: #5AF;
279+
}
280+
281+
input[type="range"]::-ms-thumb {
282+
background: #5AF;
283+
}
284+
285+
input[type="range"]::-ms-thumb {
286+
background: #5AF;
287+
}
288+
}

src/app/elements/replay/guacamole/guacamole.component.ts

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ export class ElementReplayGuacamoleComponent implements OnInit, OnChanges {
3939
leftInfo = null;
4040
winSizeChange$: Observable<any>;
4141
winSizeSub: Subscription;
42+
firstLoad = true;
43+
rangeHideClass = 'hideCursor';
44+
lastDuration: number = 0;
45+
interval: number;
4246

4347
constructor(private _http: HttpService, private _translate: TranslateService) {}
4448

@@ -98,9 +102,14 @@ export class ElementReplayGuacamoleComponent implements OnInit, OnChanges {
98102
};
99103

100104
this.recording.onprogress = (millis) => {
105+
if (millis >= this.max) {
101106
this.duration = formatTime(millis);
102107
this.max = millis;
103-
this.play();
108+
}
109+
if (!this.recording.isPlaying() && this.firstLoad) {
110+
this.recording.play();
111+
this.firstLoad = false;
112+
}
104113
};
105114

106115
// If paused, the play/pause button should read "Play"
@@ -115,6 +124,15 @@ export class ElementReplayGuacamoleComponent implements OnInit, OnChanges {
115124
}
116125
this.recordingDisplay.scale(this.getPropScale());
117126
};
127+
clearInterval(this.interval);
128+
this.interval = setInterval(() => {
129+
if (this.lastDuration === this.max) {
130+
clearInterval(this.interval);
131+
this.rangeHideClass = '';
132+
} else {
133+
this.lastDuration = this.max;
134+
}
135+
}, 1000);
118136
}
119137

120138
destroy() {
@@ -140,6 +158,10 @@ export class ElementReplayGuacamoleComponent implements OnInit, OnChanges {
140158
this.winSizeSub.unsubscribe();
141159
this.winSizeSub = null;
142160
}
161+
if (this.interval) {
162+
clearInterval(this.interval);
163+
}
164+
this.interval = null;
143165

144166
this.playerRef = null;
145167
this.displayRef = null;
@@ -154,6 +176,9 @@ export class ElementReplayGuacamoleComponent implements OnInit, OnChanges {
154176
this.commands = [];
155177
this.page = 0;
156178
this.leftInfo = null;
179+
this.firstLoad = true;
180+
this.rangeHideClass = 'hideCursor';
181+
this.lastDuration = 0;
157182
}
158183

159184
getPropScale() {
@@ -190,14 +215,17 @@ export class ElementReplayGuacamoleComponent implements OnInit, OnChanges {
190215
return date_s.split('/').join('-');
191216
}
192217

193-
runFrom() {
218+
setDisableStatusSiderElement(disable: boolean) {
194219
const sliderElement = document.getElementById('position-slider') as HTMLInputElement;
220+
sliderElement.disabled = disable;
221+
}
195222

196-
sliderElement.disabled = true;
223+
runFrom() {
224+
this.setDisableStatusSiderElement(true);
197225

198226
this.recording.seek(this.percent, () => {
199227
this.playerRef.className = '';
200-
sliderElement.disabled = false;
228+
this.setDisableStatusSiderElement(false);
201229
}
202230
);
203231

@@ -209,6 +237,7 @@ export class ElementReplayGuacamoleComponent implements OnInit, OnChanges {
209237
this.recording.play();
210238
this.playerRef.className = '';
211239
e.stopPropagation();
240+
this.setDisableStatusSiderElement(false);
212241
}
213242

214243
play() {

src/app/elements/replay/parts/parts.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
<div class="loading-spinner">
3838
<mat-spinner *ngIf="videoLoading"></mat-spinner>
3939
</div>
40-
<elements-replay-guacamole class='guacamole-video' [replay]="currentVideo" *ngIf="currentVideo?.type=='guacamole' && !videoLoading"></elements-replay-guacamole>
40+
<elements-replay-guacamole class='guacamole-video' [replay]="currentVideo" *ngIf="currentVideo"></elements-replay-guacamole>
4141
</mat-card>
4242
</div>
4343
<mat-card class="video-list">

0 commit comments

Comments
 (0)