-
-
Notifications
You must be signed in to change notification settings - Fork 190
/
Copy pathfull.component.ts
77 lines (64 loc) · 2.29 KB
/
full.component.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import type { OnInit} from '@angular/core';
import { Component, Input, Output, EventEmitter } from '@angular/core';
import { DomSanitizer } from '@angular/platform-browser';
import { FilePathService } from '../file-path.service';
import { metaAppear, textAppear } from '../../../common/animations';
import type { ImageElement } from '../../../../../interfaces/final-object.interface';
import type { RightClickEmit, VideoClickEmit } from '../../../../../interfaces/shared-interfaces';
@Component({
selector: 'app-full-item',
templateUrl: './full.component.html',
styleUrls: [
'../film-and-full.scss',
'../selected.scss'
],
animations: [ textAppear,
metaAppear ]
})
export class FullViewComponent implements OnInit {
@Output() videoClick = new EventEmitter<VideoClickEmit>();
@Output() rightClick = new EventEmitter<RightClickEmit>();
@Input()
set galleryWidth(galleryWidth: number) {
this._metaWidth = galleryWidth;
this.render();
}
@Input()
set imgHeight(imageHeight: number) {
this._imgHeight = imageHeight;
this.render();
}
@Input() video: ImageElement;
@Input() darkMode: boolean;
@Input() elHeight: number;
@Input() folderPath: string;
@Input() hubName: string;
@Input() largerFont: boolean;
@Input() showMeta: boolean;
_imgHeight: number;
_metaWidth: number;
computedWidth: number;
fullFilePath = '';
rowOffsets: number[];
constructor(
public filePathService: FilePathService,
public sanitizer: DomSanitizer
) { }
ngOnInit() {
if (this.video.type == 'image') {
this.fullFilePath = this.filePathService.createFilePath(this.folderPath, this.hubName, 'thumbnails', this.video.hash);
} else {
this.fullFilePath = this.filePathService.createFilePath(this.folderPath, this.hubName, 'filmstrips', this.video.hash);
} this.render();
}
render(): void {
const imgWidth = this._imgHeight * 16 / 9;
const imagesPerRow = Math.floor(this._metaWidth / imgWidth) || 1; // never let this be zero
this.computedWidth = imgWidth * imagesPerRow;
const numOfRows = Math.ceil((<any>(this.video || {screens: 0}).screens) / imagesPerRow);
this.rowOffsets = [];
for (let i = 0; i < numOfRows; i++) {
this.rowOffsets.push(i * Math.floor(this._metaWidth / imgWidth));
}
}
}