mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 21:06:06 +00:00
clean create event page, stop video, event list box
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user