Skip to content
Snippets Groups Projects
Commit 31580818 authored by jojohoch's avatar jojohoch
Browse files

[player] Calculate the minimum height of a page in separate page mode

parent 8db2c843
No related branches found
No related tags found
No related merge requests found
...@@ -31,13 +31,14 @@ ...@@ -31,13 +31,14 @@
[class.center-pages]="layoutAlignment === 'column' || !hasScrollPages" [class.center-pages]="layoutAlignment === 'column' || !hasScrollPages"
[class.left-container]="alwaysVisiblePagePosition === 'left'" [class.left-container]="alwaysVisiblePagePosition === 'left'"
[style.max-width]="containerMaxWidth.alwaysVisiblePage"> [style.max-width]="containerMaxWidth.alwaysVisiblePage">
<div appHideFirstChild <div [style.min-height]="'calc(100vh - ' + (alwaysVisiblePage.margin * 2) + 'px)'"
[hideFirstChild]="hidePageLabels"
[style.min-height]="'calc(100vh - ' + (alwaysVisiblePage.margin * 2) + 'px)'"
[style.background-color]="alwaysVisiblePage.backgroundColor" [style.background-color]="alwaysVisiblePage.backgroundColor"
[style.max-width]="alwaysVisiblePage.hasMaxWidth ? alwaysVisiblePage.maxWidth + 'px' : '100%'" [style.max-width]="alwaysVisiblePage.hasMaxWidth ? alwaysVisiblePage.maxWidth + 'px' : '100%'"
[style.padding.px]="alwaysVisiblePage.margin"> [style.padding.px]="alwaysVisiblePage.margin">
<div class="mat-tab-label">{{'alwaysVisiblePage' | translate}}</div> <div *ngIf="!hidePageLabels"
class="mat-tab-label">
{{'alwaysVisiblePage' | translate}}
</div>
<app-page [parentArrayIndex]="alwaysVisibleUnitPageIndex" <app-page [parentArrayIndex]="alwaysVisibleUnitPageIndex"
[parentForm]="parentForm" [parentForm]="parentForm"
[isLastPage]="false" [isLastPage]="false"
...@@ -71,12 +72,13 @@ ...@@ -71,12 +72,13 @@
<ng-template #scrollPagesSeparatedView let-pagesContainer> <ng-template #scrollPagesSeparatedView let-pagesContainer>
<mat-tab-group appHideFirstChild <mat-tab-group appHideFirstChild
[hideFirstChild]="hidePageLabels" [hideFirstChild]="hidePageLabels"
(childHeight)="tabHeaderHeight = $event"
mat-align-tabs="start" mat-align-tabs="start"
[(selectedIndex)]="selectedIndex" [(selectedIndex)]="selectedIndex"
(selectedIndexChange)="onSelectedIndexChange($event)"> (selectedIndexChange)="onSelectedIndexChange($event)">
<ng-container *ngFor="let page of scrollPages; let i = index; let last = last"> <ng-container *ngFor="let page of scrollPages; let i = index; let last = last">
<mat-tab [label]="'pageIndication' | translate: {index: i + 1}"> <mat-tab [label]="'pageIndication' | translate: {index: i + 1}">
<div [style.min-height]="'calc(100vh - ' + (page.margin * 2) + 'px)'" <div [style.min-height]="'calc(100vh - ' + ((page.margin * 2 + tabHeaderHeight)) + 'px)'"
[style.background-color]="page.backgroundColor" [style.background-color]="page.backgroundColor"
[style.padding.px]="page.margin" [style.padding.px]="page.margin"
[style.max-width]="page.hasMaxWidth ? page.maxWidth + 'px' : '100%'"> [style.max-width]="page.hasMaxWidth ? page.maxWidth + 'px' : '100%'">
...@@ -94,9 +96,7 @@ ...@@ -94,9 +96,7 @@
<ng-template #scrollPagesScrolledView let-pagesContainer> <ng-template #scrollPagesScrolledView let-pagesContainer>
<ng-container *ngFor="let page of scrollPages; let i = index; let last = last"> <ng-container *ngFor="let page of scrollPages; let i = index; let last = last">
<div appHideFirstChild <div [style.min-height]="'calc(100vh - ' + (page.margin * 2) + 'px)'"
[hideFirstChild]="hidePageLabels"
[style.min-height]="'calc(100vh - ' + (page.margin * 2) + 'px)'"
[style.background-color]="page.backgroundColor" [style.background-color]="page.backgroundColor"
[class.concat-scroll-snap-align]="scrollPageMode === 'concat-scroll-snap'" [class.concat-scroll-snap-align]="scrollPageMode === 'concat-scroll-snap'"
[style.max-width]="page.hasMaxWidth ? page.maxWidth + 'px' : '100%'" [style.max-width]="page.hasMaxWidth ? page.maxWidth + 'px' : '100%'"
...@@ -105,7 +105,8 @@ ...@@ -105,7 +105,8 @@
[pagesContainer]="pagesContainer" [pagesContainer]="pagesContainer"
[selectIndex]="selectIndex" [selectIndex]="selectIndex"
[index]="i"> [index]="i">
<div class="mat-tab-label"> <div *ngIf="!hidePageLabels"
class="mat-tab-label">
{{'pageIndication' | translate: {index: i + 1} }} {{'pageIndication' | translate: {index: i + 1} }}
</div> </div>
<app-page [parentArrayIndex]="scrollPagesIndices[i]" <app-page [parentArrayIndex]="scrollPagesIndices[i]"
......
...@@ -51,7 +51,8 @@ export class LayoutComponent implements OnInit, AfterViewInit, OnDestroy { ...@@ -51,7 +51,8 @@ export class LayoutComponent implements OnInit, AfterViewInit, OnDestroy {
alwaysVisiblePagePosition!: 'top' | 'bottom' | 'left' | 'right' ; alwaysVisiblePagePosition!: 'top' | 'bottom' | 'left' | 'right' ;
layoutAlignment!: 'row' | 'column'; layoutAlignment!: 'row' | 'column';
scrollPageMode!: 'separate' | 'concat-scroll' | 'concat-scroll-snap'; scrollPageMode!: 'separate' | 'concat-scroll' | 'concat-scroll-snap';
hidePageLabels!: boolean; hidePageLabels: boolean = true;
tabHeaderHeight: number = 0;
maxWidth: { alwaysVisiblePage: number, scrollPages: number, allPages: number } = maxWidth: { alwaysVisiblePage: number, scrollPages: number, allPages: number } =
{ alwaysVisiblePage: 0, scrollPages: 0, allPages: 0 }; { alwaysVisiblePage: 0, scrollPages: 0, allPages: 0 };
...@@ -138,7 +139,6 @@ export class LayoutComponent implements OnInit, AfterViewInit, OnDestroy { ...@@ -138,7 +139,6 @@ export class LayoutComponent implements OnInit, AfterViewInit, OnDestroy {
this.layoutAlignment = (this.alwaysVisiblePagePosition === 'left' || this.alwaysVisiblePagePosition === 'right') ? this.layoutAlignment = (this.alwaysVisiblePagePosition === 'left' || this.alwaysVisiblePagePosition === 'right') ?
'row' : 'column'; 'row' : 'column';
this.scrollPageMode = this.playerConfig.pagingMode ? this.playerConfig.pagingMode : 'separate'; this.scrollPageMode = this.playerConfig.pagingMode ? this.playerConfig.pagingMode : 'separate';
this.hidePageLabels = true;
this.maxWidth.alwaysVisiblePage = this.getAbsolutePageWidth(this.alwaysVisiblePage); this.maxWidth.alwaysVisiblePage = this.getAbsolutePageWidth(this.alwaysVisiblePage);
this.maxWidth.scrollPages = this.getScrollPagesWidth(); this.maxWidth.scrollPages = this.getScrollPagesWidth();
......
import { import {
Directive, ElementRef, Input AfterViewInit,
Directive, ElementRef, EventEmitter, Input, OnDestroy, OnInit, Output
} from '@angular/core'; } from '@angular/core';
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
import { NativeEventService } from '../services/native-event.service';
@Directive({ @Directive({
selector: '[appHideFirstChild]' selector: '[appHideFirstChild]'
}) })
export class HideFirstChildDirective { export class HideFirstChildDirective implements OnInit, AfterViewInit, OnDestroy {
@Input() hideFirstChild!: boolean; @Input() hideFirstChild!: boolean;
@Output() childHeight = new EventEmitter<number>();
constructor(private elementRef: ElementRef) {} private ngUnsubscribe = new Subject<void>();
constructor(
private elementRef: ElementRef,
private nativeEventService: NativeEventService
) {}
ngOnInit(): void { ngOnInit(): void {
if (this.hideFirstChild && this.elementRef.nativeElement.firstChild) { if (this.elementRef.nativeElement.firstChild) {
this.elementRef.nativeElement.firstChild.style.display = 'none'; if (this.hideFirstChild) {
// default usage: hide element!
this.elementRef.nativeElement.firstChild.style.display = 'none';
} else {
// otherwise: send its height to handle it
this.nativeEventService.resize
.pipe(takeUntil(this.ngUnsubscribe))
.subscribe(() => this.emitHeight());
}
}
}
ngAfterViewInit(): void {
if (this.elementRef.nativeElement.firstChild && !this.hideFirstChild) {
this.emitHeight();
} }
} }
private emitHeight() {
this.childHeight.emit(this.elementRef.nativeElement.firstChild.offsetHeight);
}
ngOnDestroy(): void {
this.ngUnsubscribe.next();
this.ngUnsubscribe.complete();
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment