Merge branch 'feature/shared-content' of https://bitbucket.org/equilibriumito/gabinete-digital-fo into feature/shared-content

This commit is contained in:
Eudes Inácio
2023-12-01 12:19:37 +01:00
12 changed files with 155 additions and 24 deletions
@@ -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,33 @@
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
};
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);
}
}
@@ -0,0 +1,16 @@
import { TestBed } from '@angular/core/testing';
import { PublicationVideoManagerService } from './publication-video-manager.service';
describe('PublicationVideoManagerService', () => {
let service: PublicationVideoManagerService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(PublicationVideoManagerService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
});
@@ -0,0 +1,35 @@
import { Injectable } from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class PublicationVideoManagerService {
container: HTMLDivElement
scrollLimit: number = 0
selectedVideo: SelectedPublication
constructor() {}
setSelectedVideo(selectedVideo: SelectedPublication) {
this.selectedVideo = selectedVideo
}
setContainer(element: HTMLDivElement) {
this.container = element
console.log(this.container, "container")
}
}
class SelectedPublication {
position: number
video: HTMLVideoElement
constructor({position, video}) {
this.position = position
this.video = video
}
}