openvidu-components: Fixed layout bug.

The layout has a bad UX. The root element is created with the entire layout width and it has a weird UX behaviour. Custom class with no width and height has been added and removed dynamically when stream container is present.
pull/707/head
csantosm 2022-02-24 13:02:00 +01:00
parent b52ca52e1d
commit 1bf3ce1bc9
10 changed files with 28 additions and 38 deletions

View File

@ -22,9 +22,6 @@
* http://opensource.org/licenses/MIT * http://opensource.org/licenses/MIT
*/ */
.custom-class {
min-height: 0px !important;
}
/** /**
* OT Base styles * OT Base styles
@ -38,9 +35,7 @@
padding: 0; padding: 0;
border: 0; border: 0;
font-size: 100%; font-size: 100%;
font-family: 'Ubuntu', sans-serif;
vertical-align: baseline; vertical-align: baseline;
transition: all .1s linear;
} }
.OT_dialog-centering { .OT_dialog-centering {
@ -220,9 +215,11 @@
.OT_publisher, .OT_publisher,
.OT_subscriber { .OT_subscriber {
position: relative; position: relative;
min-width: 48px; min-width: 0px;
min-height: 48px; min-height: 0px;
margin: 1px; margin: 1px;
transition-duration: 0.1s;
transition-timing-function: ease-in-out;
} }
.OT_publisher .OT_video-element, .OT_publisher .OT_video-element,
@ -231,20 +228,10 @@
position: absolute; position: absolute;
width: 100%; width: 100%;
height: 100%; height: 100%;
-webkit-transform-origin: 0 0; -webkit-transform-origin: 0 0;
transform-origin: 0 0; transform-origin: 0 0;
} }
/* Styles that are applied when the video element should be mirrored */
.OT_publisher.OT_mirrored .OT_video-element {
-webkit-transform: scale(-1, 1);
transform: scale(-1, 1);
-webkit-transform-origin: 50% 50%;
transform-origin: 50% 50%;
}
.OT_subscriber_error { .OT_subscriber_error {
background-color: #000; background-color: #000;
color: #fff; color: #fff;

View File

@ -1,7 +1,6 @@
<div id="layout" class="layout"> <div id="layout" class="layout">
<div <div
class="OT_root OT_publisher" class="OT_root OT_publisher"
id="localUser"
*ngFor="let stream of localParticipant | streams" *ngFor="let stream of localParticipant | streams"
[ngClass]="{ OV_small: !stream.streamManager?.stream?.videoActive }" [ngClass]="{ OV_small: !stream.streamManager?.stream?.videoActive }"
> >

View File

@ -1,3 +1,10 @@
/* Fixes layout bug. The OT_root is created with the entire layout width and it has a weird UX behaviour */
.no-size {
height: 0px !important;
width: 0px !important;
}
.nickname { .nickname {
padding: 0px; padding: 0px;
position: absolute; position: absolute;

View File

@ -1,6 +1,6 @@
<div <div
*ngIf="this._stream" *ngIf="this._stream"
class="OT_widget-container" class="OT_widget-container no-size"
[id]="'container-' + this._stream.streamManager?.stream?.streamId" [id]="'container-' + this._stream.streamManager?.stream?.streamId"
#streamContainer #streamContainer
> >

View File

@ -46,14 +46,6 @@ export class StreamComponent implements OnInit {
protected cdkSrv: CdkOverlayService protected cdkSrv: CdkOverlayService
) {} ) {}
// @HostListener('document:fullscreenchange', ['$event'])
// @HostListener('document:webkitfullscreenchange', ['$event'])
// @HostListener('document:mozfullscreenchange', ['$event'])
// @HostListener('document:MSFullscreenChange', ['$event'])
// onFullscreenHandler(event) {
// this.isFullscreenEnabled = !this.isFullscreenEnabled;
// }
@ViewChild('streamContainer', { static: false, read: ElementRef }) @ViewChild('streamContainer', { static: false, read: ElementRef })
set streamContainer(streamContainer: ElementRef) { set streamContainer(streamContainer: ElementRef) {
setTimeout(() => { setTimeout(() => {
@ -62,6 +54,10 @@ export class StreamComponent implements OnInit {
if (this._stream.type === VideoType.SCREEN) { if (this._stream.type === VideoType.SCREEN) {
this.toggleVideoEnlarged(true); this.toggleVideoEnlarged(true);
} }
// Remove 'no-size' css class for showing the element in the view.
// This is a workaround for fixing a layout bug which provide a bad UX with each new elements created.
//
this.documentService.removeNoSizeElementClass(this._streamContainer.nativeElement);
} }
}, 0); }, 0);
} }

View File

@ -1,3 +1,4 @@
import { THIS_EXPR } from '@angular/compiler/src/output/output_ast';
import { AfterViewInit, Component, ElementRef, Input, ViewChild } from '@angular/core'; import { AfterViewInit, Component, ElementRef, Input, ViewChild } from '@angular/core';
import { StreamManager } from 'openvidu-browser'; import { StreamManager } from 'openvidu-browser';
import { VideoType } from '../../models/video-type.model'; import { VideoType } from '../../models/video-type.model';
@ -43,7 +44,7 @@ export class VideoComponent implements AfterViewInit {
@Input() @Input()
set streamManager(streamManager: StreamManager) { set streamManager(streamManager: StreamManager) {
setTimeout(() => { if(streamManager) {
this._streamManager = streamManager; this._streamManager = streamManager;
if (!!this._videoElement && this._streamManager) { if (!!this._videoElement && this._streamManager) {
this.type = <VideoType>this._streamManager?.stream?.typeOfVideo; this.type = <VideoType>this._streamManager?.stream?.typeOfVideo;
@ -55,6 +56,6 @@ export class VideoComponent implements AfterViewInit {
} }
this._streamManager.addVideoElement(this._videoElement.nativeElement); this._streamManager.addVideoElement(this._videoElement.nativeElement);
} }
}); }
} }
} }

View File

@ -2,7 +2,8 @@ export enum LayoutClass {
ROOT_ELEMENT = 'OT_root', ROOT_ELEMENT = 'OT_root',
BIG_ELEMENT = 'OV_big', BIG_ELEMENT = 'OV_big',
SMALL_ELEMENT = 'OV_small', SMALL_ELEMENT = 'OV_small',
SIDENAV_CONTAINER = 'sidenav-container' SIDENAV_CONTAINER = 'sidenav-container',
NO_SIZE_ELEMENT = 'no-size'
} }
export enum SidenavMode { export enum SidenavMode {

View File

@ -55,6 +55,11 @@ export class DocumentService {
} }
} }
removeNoSizeElementClass(element: HTMLElement | Element) {
element?.classList.remove(LayoutClass.NO_SIZE_ELEMENT);
}
removeBigElementClass(element: HTMLElement | Element) { removeBigElementClass(element: HTMLElement | Element) {
element?.classList.remove(LayoutClass.BIG_ELEMENT); element?.classList.remove(LayoutClass.BIG_ELEMENT);
} }

View File

@ -46,7 +46,7 @@ export class LayoutService {
bigMaxRatio: 9 / 16, // The narrowest ratio to use for the big elements (default 2x3) bigMaxRatio: 9 / 16, // The narrowest ratio to use for the big elements (default 2x3)
bigMinRatio: 9 / 16, // The widest ratio to use for the big elements (default 16x9) bigMinRatio: 9 / 16, // The widest ratio to use for the big elements (default 16x9)
bigFirst: true, // Whether to place the big one in the top left (true) or bottom right bigFirst: true, // Whether to place the big one in the top left (true) or bottom right
animate: true // Whether you want to animate the transitions. Invalid property, to disable it remove transition: all .1s linear; animate: true // Whether you want to animate the transitions. Deprecated property, to disable it remove the transaction property on OT_publisher css class
}; };
return options; return options;
} }

View File

@ -162,13 +162,7 @@ export class OpenViduService {
async initPublisher(targetElement: string | HTMLElement, properties: PublisherProperties): Promise<Publisher> { async initPublisher(targetElement: string | HTMLElement, properties: PublisherProperties): Promise<Publisher> {
this.log.d('Initializing publisher with properties: ', properties); this.log.d('Initializing publisher with properties: ', properties);
return await this.OV.initPublisherAsync(targetElement, properties);
const publisher = await this.OV.initPublisherAsync(targetElement, properties);
// this.participantService.setMyCameraPublisher(publisher);
publisher.once('streamPlaying', () => {
(<HTMLElement>publisher.videos[0].video).parentElement.classList.remove('custom-class');
});
return publisher;
} }
//TODO: This method is used by republishTrack. Check if it's neecessary //TODO: This method is used by republishTrack. Check if it's neecessary