Move files and add minor fixes

This commit is contained in:
Andras Schmelczer 2022-09-24 21:52:25 +02:00
parent 6fbc15c402
commit 51c8d06569
No known key found for this signature in database
GPG key ID: 0EA1BC97D0AB076E
16 changed files with 89 additions and 105 deletions

34
src/page/video/video.ts Normal file
View file

@ -0,0 +1,34 @@
import { createElement } from '../../helper/create-element';
import { PageElement } from '../page-element';
import { VideoParameters } from './video-parameters';
import { generate } from './video.html';
export class Video extends PageElement {
private video: HTMLVideoElement;
public constructor(options: VideoParameters) {
super(createElement(generate(options)));
this.video = this.query('video') as HTMLVideoElement;
this.htmlRoot.addEventListener('click', this.startVideo.bind(this));
this.query('.start-button').addEventListener('click', this.startVideo.bind(this));
this.video.addEventListener('pause', this.pauseVideo.bind(this));
}
private startVideo() {
if (this.video.paused) {
this.query('.start-button').style.visibility = 'hidden';
this.htmlRoot.classList.add('loaded');
this.video.play();
this.video.controls = true;
}
}
private pauseVideo() {
if (this.video.paused) {
this.query('.start-button').style.visibility = 'visible';
this.video.controls = false;
}
}
}