Updated site to use momentum for contacting, registration, gallery and calendar, as well as some other updates to the site content
This commit is contained in:
24
src/app/directives/in-view.directive.ts
Normal file
24
src/app/directives/in-view.directive.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import {Directive, ElementRef, EventEmitter, OnDestroy, OnInit, Output} from '@angular/core';
|
||||
|
||||
@Directive({selector: '[inView]'})
|
||||
export class InViewDirective implements OnInit, OnDestroy {
|
||||
@Output() inView = new EventEmitter<void>();
|
||||
private observer!: IntersectionObserver;
|
||||
|
||||
constructor(private el: ElementRef) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.observer = new IntersectionObserver(([entry]) => {
|
||||
if (entry.isIntersecting) {
|
||||
this.inView.emit();
|
||||
this.observer.disconnect();
|
||||
}
|
||||
}, {rootMargin: '200px'});
|
||||
|
||||
this.observer.observe(this.el.nativeElement);
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.observer.disconnect();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user