-
-
Notifications
You must be signed in to change notification settings - Fork 190
/
Copy pathdetails.component.ts
111 lines (92 loc) · 3.4 KB
/
details.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import type { OnInit, ElementRef} from '@angular/core';
import { Component, Input, ViewChild, Output, EventEmitter } from '@angular/core';
import { DomSanitizer } from '@angular/platform-browser';
import type { BehaviorSubject } from 'rxjs';
import { FilePathService } from '../file-path.service';
import { ManualTagsService } from '../../tags-manual/manual-tags.service';
import type { StarRating, ImageElement } from '../../../../../interfaces/final-object.interface';
import type { VideoClickEmit, RightClickEmit, TagEmit, RenameFileResponse } from '../../../../../interfaces/shared-interfaces';
export interface YearEmission {
index: number;
year: number;
}
@Component({
selector: 'app-details-item',
templateUrl: './details.component.html',
styleUrls: [
'./details.component.scss',
'../selected.scss'
]
})
export class DetailsComponent implements OnInit {
@ViewChild('filmstripHolder', { static: false }) filmstripHolder: ElementRef;
@Output() filterTag = new EventEmitter<TagEmit>();
@Output() videoClick = new EventEmitter<VideoClickEmit>();
@Output() rightClick = new EventEmitter<RightClickEmit>();
@Input() video: ImageElement;
@Input() maxWidth: number;
@Input() showTwoColumns: boolean;
@Input() darkMode: boolean;
@Input() elHeight: number;
@Input() elWidth: number;
@Input() folderPath: string;
@Input() hoverScrub: boolean;
@Input() hubName: string;
@Input() imgHeight: number;
@Input() largerFont: boolean;
@Input() returnToFirstScreenshot: boolean;
@Input() selectedSourceFolder: string;
@Input() showAutoFileTags: boolean;
@Input() showAutoFolderTags: boolean;
@Input() showManualTags: boolean;
@Input() showMeta: boolean;
@Input() showVideoNotes: boolean;
@Input() star: StarRating;
@Input() renameResponse: BehaviorSubject<RenameFileResponse>;
containerWidth: number;
filmstripPath = '';
firstFilePath = '';
hover: boolean;
indexToShow = 1;
percentOffset = 0;
constructor(
public filePathService: FilePathService,
public manualTagsService: ManualTagsService,
public sanitizer: DomSanitizer
) { }
mouseEnter() {
if (this.hoverScrub) {
this.containerWidth = this.filmstripHolder.nativeElement.getBoundingClientRect().width;
this.hover = true;
}
}
mouseLeave() {
if (this.hoverScrub && this.returnToFirstScreenshot) {
this.hover = false;
this.percentOffset = (this.video.defaultScreen !== undefined)
? this.getDefaultScreenOffset(this.video)
: 0;
}
}
getDefaultScreenOffset(video: ImageElement): number {
return 100 * video.defaultScreen / (video.screens - 1);
}
ngOnInit() {
this.firstFilePath = this.filePathService.createFilePath(this.folderPath, this.hubName, 'thumbnails', this.video.hash);
if (this.video.type == 'image') {
this.filmstripPath = this.firstFilePath;
} else {
this.filmstripPath = this.filePathService.createFilePath(this.folderPath, this.hubName, 'filmstrips', this.video.hash);
}
if (this.video.defaultScreen !== undefined) {
this.percentOffset = this.getDefaultScreenOffset(this.video);
}
}
mouseIsMoving($event) {
if (this.hoverScrub) {
const cursorX = $event.layerX;
this.indexToShow = Math.floor(cursorX * (this.video.screens / this.containerWidth));
this.percentOffset = this.indexToShow * (100 / (this.video.screens - 1));
}
}
}