clean create event page, stop video, event list box

This commit is contained in:
Peter Maquiran
2023-12-06 12:07:22 +01:00
26 changed files with 351 additions and 79 deletions
@@ -15,6 +15,9 @@ export class VisibilityDirective {
threshold: 0.5 // Adjust as needed
};
console.log(this.elementRef.nativeElement.parentElement, "=1=")
this.intersectionObserver = new IntersectionObserver(entries => {
entries.forEach(entry => {
if (entry.isIntersecting) {
@@ -0,0 +1,8 @@
import { VisibilityDirective } from './visibility.directive';
describe('VisibilityDirective', () => {
it('should create an instance', () => {
const directive = new VisibilityDirective();
expect(directive).toBeTruthy();
});
});
@@ -0,0 +1,36 @@
import { Directive, ElementRef, Input } from '@angular/core';
@Directive({
selector: '[appVisibility]'
})
export class VisibilityDirective {
intersectionObserver: IntersectionObserver;
@Input() appVisibility: (arg: any) => void;
constructor(private elementRef: ElementRef) {
const options = {
root: null,
rootMargin: '0px',
threshold: 0.5 // Adjust as needed
};
console.log(this.elementRef.nativeElement.parentElement, "=1=")
this.intersectionObserver = new IntersectionObserver(entries => {
entries.forEach(entry => {
if (entry.isIntersecting) {
this.appVisibility(true);
} else {
this.elementRef.nativeElement.pause()
// Pause video when not visible
this.appVisibility(false); // You can implement pause logic here
}
});
}, options);
this.intersectionObserver.observe(this.elementRef.nativeElement);
}
}