edit actions and video stop

This commit is contained in:
Peter Maquiran
2023-12-13 16:44:29 +01:00
parent 5e8c4187fa
commit d2c1e100cc
13 changed files with 251 additions and 19 deletions
@@ -1,5 +1,5 @@
import { Directive, ElementRef, Input } from '@angular/core';
import { StopvideoService } from "src/app/services/stopvideo.service";
@Directive({
selector: '[appVisibility]'
})
@@ -8,7 +8,10 @@ export class VisibilityDirective {
intersectionObserver: IntersectionObserver;
@Input() appVisibility: (arg: any) => void;
constructor(private elementRef: ElementRef) {
constructor(
private elementRef: ElementRef,
private stopvideoService: StopvideoService
) {
const options = {
root: null,
rootMargin: '0px',
@@ -16,12 +19,13 @@ export class VisibilityDirective {
};
console.log(this.elementRef.nativeElement.parentElement, "=1=")
// this.stopvideoService.registerVideo()
this.intersectionObserver = new IntersectionObserver(entries => {
entries.forEach(entry => {
if (entry.isIntersecting) {
this.appVisibility(true);
this.stopvideoService.registerVideo(this.elementRef.nativeElement);
} else {
this.elementRef.nativeElement.pause()
// Pause video when not visible
@@ -1,4 +1,5 @@
import { Directive, ElementRef, Input } from '@angular/core';
import { StopvideoService } from '../stopvideo.service';
@Directive({
selector: '[appVisibility]'
@@ -8,7 +9,10 @@ export class VisibilityDirective {
intersectionObserver: IntersectionObserver;
@Input() appVisibility: (arg: any) => void;
constructor(private elementRef: ElementRef) {
constructor(
private elementRef: ElementRef,
private stopvideoService: StopvideoService
) {
const options = {
root: null,
rootMargin: '0px',
@@ -16,12 +20,11 @@ export class VisibilityDirective {
};
console.log(this.elementRef.nativeElement.parentElement, "=1=")
this.intersectionObserver = new IntersectionObserver(entries => {
entries.forEach(entry => {
if (entry.isIntersecting) {
this.appVisibility(true);
this.stopvideoService.registerVideo(this.elementRef.nativeElement)
} else {
this.elementRef.nativeElement.pause()
// Pause video when not visible