"import {Observable} from 'rxjs';\r\nimport {takeUntil} from 'rxjs/operators';\r\nimport { MonoTypeOperatorFunction } from 'rxjs/interfaces';\r\n\r\n// create a symbol identify the observable I add to\r\n// the component so it doesn't conflict with anything.\r\n// I need this so I'm able to add the desired behaviour to the component.\r\nexport const destroy$ = 'destroy$';\r\n\r\n/**\r\n * An operator that takes until destroy it takes a components this a parameter\r\n * returns a pipeable RxJS operator.\r\n */\r\nexport const untilDestroy = <T>(component: any): MonoTypeOperatorFunction<T> => {\r\n if (component[destroy$] === undefined) {\r\n // only hookup each component once.\r\n addDestroyObservableToComponent(component);\r\n }\r\n\r\n // pipe in the takeUntil destroy$ and return the source unaltered\r\n return takeUntil<T>(component[destroy$]);\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function addDestroyObservableToComponent(component: any) {\r\n component[destroy$] = new Observable<void>(observer => {\r\n // keep track of the original destroy function,\r\n // the user might do something in there\r\n const orignalDestroy = component.ngOnDestroy;\r\n if (orignalDestroy == null) {\r\n // Angular does not support dynamic added destroy methods\r\n // so make sure there is one.\r\n throw new Error('untilDestroy operator needs the component to have an ngOnDestroy method');\r\n }\r\n // replace the ngOndestroy\r\n component.ngOnDestroy = () => {\r\n // fire off the destroy observable\r\n observer.next();\r\n // complete the observable\r\n observer.complete();\r\n // and at last, call the original destroy\r\n orignalDestroy.call(component);\r\n };\r\n // return cleanup function.\r\n return (_: any) => (component[destroy$] = undefined);\r\n });\r\n}\r\n",
"import {Directive, ElementRef, EventEmitter, Inject, Input, OnDestroy, OnInit, Output, PLATFORM_ID,} from '@angular/core';\r\nimport {isPlatformBrowser} from '@angular/common';\r\nimport {filter, take} from 'rxjs/operators';\r\nimport {ViewportService} from '../services';\r\nimport {untilDestroy} from '../operators';\r\n\r\n@Directive({\r\n selector: '[aiutInViewport]',\r\n})\r\nexport class InViewportDirective implements OnInit, OnDestroy {\r\n @Input() public preRender = true;\r\n @Input() public oneTime = false;\r\n @Output() readonly inViewport = new EventEmitter<Partial<IntersectionObserverEntry>>();\r\n\r\n constructor(\r\n private readonly elementRef: ElementRef,\r\n private viewportService: ViewportService,\r\n @Inject(PLATFORM_ID) private platformId: Object,\r\n ) {\r\n }\r\n\r\n public ngOnInit() {\r\n if (isPlatformBrowser(this.platformId)) {\r\n if (this.oneTime) {\r\n this.viewportService\r\n .observe(this.elementRef.nativeElement)\r\n .pipe(\r\n untilDestroy(this),\r\n filter(entry => entry.intersectionRatio >= 0.5),\r\n take(1),\r\n )\r\n .subscribe((entry: IntersectionObserverEntry) => {\r\n this.inViewport.emit(entry);\r\n });\r\n } else {\r\n this.viewportService\r\n .observe(this.elementRef.nativeElement)\r\n .pipe(untilDestroy(this))\r\n .subscribe((entry: IntersectionObserverEntry) => {\r\n this.inViewport.emit(entry);\r\n });\r\n }\r\n } else {\r\n if (this.preRender) {\r\n this.inViewport.emit({isIntersecting: true, intersectionRatio: 1});\r\n }\r\n }\r\n }\r\n\r\n ngOnDestroy() {\r\n }\r\n}\r\n",
"import {Observable} from 'rxjs';\r\nimport {takeUntil} from 'rxjs/operators';\r\nimport {MonoTypeOperatorFunction} from 'rxjs/interfaces';\r\n\r\n// create a symbol identify the observable I add to\r\n// the component so it doesn't conflict with anything.\r\n// I need this so I'm able to add the desired behaviour to the component.\r\nconst destroy$ = 'destroy$';\r\n\r\n/**\r\n * An operator that takes until destroy it takes a components this a parameter\r\n * returns a pipeable RxJS operator.\r\n */\r\nexport const untilDestroy = <T>(component: any): MonoTypeOperatorFunction<T> => {\r\n if (component[destroy$] === undefined) {\r\n // only hookup each component once.\r\n addDestroyObservableToComponent(component);\r\n }\r\n\r\n // pipe in the takeUntil destroy$ and return the source unaltered\r\n return takeUntil<T>(component[destroy$]);\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nfunction addDestroyObservableToComponent(component: any) {\r\n component[destroy$] = new Observable<void>(observer => {\r\n // keep track of the original destroy function,\r\n // the user might do something in there\r\n const orignalDestroy = component.ngOnDestroy;\r\n if (orignalDestroy == null) {\r\n // Angular does not support dynamic added destroy methods\r\n // so make sure there is one.\r\n throw new Error('untilDestroy operator needs the component to have an ngOnDestroy method');\r\n }\r\n // replace the ngOndestroy\r\n component.ngOnDestroy = () => {\r\n // fire off the destroy observable\r\n observer.next();\r\n // complete the observable\r\n observer.complete();\r\n // and at last, call the original destroy\r\n orignalDestroy.call(component);\r\n };\r\n // return cleanup function.\r\n return (_: any) => (component[destroy$] = undefined);\r\n });\r\n}\r\n",
"import {Directive, ElementRef, EventEmitter, Inject, Input, OnDestroy, OnInit, Output, PLATFORM_ID} from '@angular/core';\r\nimport {isPlatformBrowser} from '@angular/common';\r\nimport {filter, take} from 'rxjs/operators';\r\nimport {ViewportService} from '../services';\r\nimport {untilDestroy} from '../operators';\r\n\r\n@Directive({\r\n selector: '[aiutInViewport]',\r\n})\r\nexport class InViewportDirective implements OnInit, OnDestroy {\r\n @Input() public preRender = true;\r\n @Input() public oneTime = false;\r\n @Output() readonly inViewport = new EventEmitter<Partial<MyIntersectionObserverEntry>>();\r\n\r\n constructor(\r\n private readonly elementRef: ElementRef,\r\n private viewportService: ViewportService,\r\n @Inject(PLATFORM_ID) private platformId: Object,\r\n ) {\r\n }\r\n\r\n public ngOnInit() {\r\n if (isPlatformBrowser(this.platformId)) {\r\n if (this.oneTime) {\r\n this.viewportService\r\n .observe(this.elementRef.nativeElement)\r\n .pipe(\r\n untilDestroy(this),\r\n filter(entry => entry.intersectionRatio >= 0.5),\r\n take(1),\r\n )\r\n .subscribe((entry: MyIntersectionObserverEntry) => {\r\n this.inViewport.emit(entry);\r\n });\r\n } else {\r\n this.viewportService\r\n .observe(this.elementRef.nativeElement)\r\n .pipe(untilDestroy(this))\r\n .subscribe((entry: MyIntersectionObserverEntry) => {\r\n this.inViewport.emit(entry);\r\n });\r\n }\r\n } else {\r\n if (this.preRender) {\r\n this.inViewport.emit({isIntersecting: true, intersectionRatio: 1});\r\n }\r\n }\r\n }\r\n\r\n ngOnDestroy() {\r\n }\r\n}\r\n\r\nexport interface MyIntersectionObserverEntry extends IntersectionObserverEntry {\r\n readonly isIntersecting: boolean;\r\n}\r\n",
"import {NgModule} from '@angular/core';\r\nimport {CommonModule} from '@angular/common';\r\n\r\nimport * as Components from './components';\r\nimport * as Directives from './directives';\r\nimport * as Services from './services';\r\n\r\n@NgModule({\r\n imports: [CommonModule],\r\n declarations: [Directives.InViewportDirective, Components.InViewportComponent],\r\n providers: [Services.ViewportService],\r\n exports: [Directives.InViewportDirective, Components.InViewportComponent]\r\n})\r\nexport class AitpUtilsModule { }\r\n"
!function(e,t){"object"==typeofexports&&"undefined"!=typeofmodule?t(exports,require("@angular/common"),require("@angular/core"),require("rxjs"),require("rxjs/operators")):"function"==typeofdefine&&define.amd?define("aitp-utils",["exports","@angular/common","@angular/core","rxjs","rxjs/operators"],t):t(e["aitp-utils"]={},e.ng.common,e.ng.core,e.rxjs,e.rxjs.operators)}(this,function(e,r,n,t,o){"use strict";vari=function(){functione(e){this.changeDetectorRef=e}returne.prototype.onViewportChange=function(e){e.isIntersecting?this.changeDetectorRef.reattach():this.changeDetectorRef.detach()},e.decorators=[{type:n.Component,args:[{selector:"aiut-in-viewport",template:'<div (inViewport)="onViewportChange($event)" aiutInViewport>\r\n <ng-content></ng-content>\r\n</div>\r\n'}]}],e.ctorParameters=function(){return[{type:n.ChangeDetectorRef}]},e}(),s=function(){functione(){this.options={rootMargin:"0px 0px 0px 0px",threshold:[.5]},this.callback$=newt.Subject,this.observer=newIntersectionObserver(this.handler.bind(this),this.options)}returne.prototype.observe=function(t){vare=this;returnthis.observer.observe(t),this.callback$.asObservable().pipe(o.filter(function(e){returne.target===t}),o.finalize(function(){returne.observer.unobserve(t)}))},e.prototype.handler=function(e){vart=this;e.forEach(function(e){returnt.callback$.next(e)})},e.decorators=[{type:n.Injectable}],e.ctorParameters=function(){return[]},e}(),c="destroy$",a=function(e){returne[c]===undefined&&p(e),o.takeUntil(e[c])};functionp(r){r[c]=newt.Observable(function(e){vart=r.ngOnDestroy;if(null==t)thrownewError("untilDestroy operator needs the component to have an ngOnDestroy method");returnr.ngOnDestroy=function(){e.next(),e.complete(),t.call(r)},function(e){returnr[c]=undefined}})}varu=function(){functione(e,t,r){this.elementRef=e,this.viewportService=t,this.platformId=r,this.preRender=!0,this.oneTime=!1,this.inViewport=newn.EventEmitter}returne.prototype.ngOnInit=function(){vart=this;r.isPlatformBrowser(this.platformId)?this.oneTime?this.viewportService.observe(this.elementRef.nativeElement).pipe(a(this),o.filter(function(e){return.5<=e.intersectionRatio}),o.take(1)).subscribe(function(e){t.inViewport.emit(e)}):this.viewportService.observe(this.elementRef.nativeElement).pipe(a(this)).subscribe(function(e){t.inViewport.emit(e)}):this.preRender&&this.inViewport.emit({isIntersecting:!0,intersectionRatio:1})},e.prototype.ngOnDestroy=function(){},e.decorators=[{type:n.Directive,args:[{selector:"[aiutInViewport]"}]}],e.ctorParameters=function(){return[{type:n.ElementRef},{type:s},{type:Object,decorators:[{type:n.Inject,args:[n.PLATFORM_ID]}]}]},e.propDecorators={preRender:[{type:n.Input}],oneTime:[{type:n.Input}],inViewport:[{type:n.Output}]},e}(),f=function(){functione(){}returne.decorators=[{type:n.NgModule,args:[{imports:[r.CommonModule],declarations:[u,i],providers:[s],exports:[u,i]}]}],e}();e.AitpUtilsModule=f,e.InViewportComponent=i,e.InViewportDirective=u,e.addDestroyObservableToComponent=p,e.destroy$=c,e.untilDestroy=a,e.ViewportService=s,e.ɵb=i,e.ɵa=u,e.ɵc=s,Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,t){"object"==typeofexports&&"undefined"!=typeofmodule?t(exports,require("@angular/common"),require("@angular/core"),require("rxjs"),require("rxjs/operators")):"function"==typeofdefine&&define.amd?define("aitp-utils",["exports","@angular/common","@angular/core","rxjs","rxjs/operators"],t):t(e["aitp-utils"]={},e.ng.common,e.ng.core,e.rxjs,e.rxjs.operators)}(this,function(e,r,n,o,i){"use strict";vart=function(){functione(e){this.changeDetectorRef=e}returne.prototype.onViewportChange=function(e){e.isIntersecting?this.changeDetectorRef.reattach():this.changeDetectorRef.detach()},e.decorators=[{type:n.Component,args:[{selector:"aiut-in-viewport",template:'<div (inViewport)="onViewportChange($event)" aiutInViewport>\r\n <ng-content></ng-content>\r\n</div>\r\n'}]}],e.ctorParameters=function(){return[{type:n.ChangeDetectorRef}]},e}(),s=function(){functione(){this.options={rootMargin:"0px 0px 0px 0px",threshold:[.5]},this.callback$=newo.Subject,this.observer=newIntersectionObserver(this.handler.bind(this),this.options)}returne.prototype.observe=function(t){vare=this;returnthis.observer.observe(t),this.callback$.asObservable().pipe(i.filter(function(e){returne.target===t}),i.finalize(function(){returne.observer.unobserve(t)}))},e.prototype.handler=function(e){vart=this;e.forEach(function(e){returnt.callback$.next(e)})},e.decorators=[{type:n.Injectable}],e.ctorParameters=function(){return[]},e}(),c="destroy$",p=function(e){returne[c]===undefined&&functiont(r){r[c]=newo.Observable(function(e){vart=r.ngOnDestroy;if(null==t)thrownewError("untilDestroy operator needs the component to have an ngOnDestroy method");returnr.ngOnDestroy=function(){e.next(),e.complete(),t.call(r)},function(e){returnr[c]=undefined}})}(e),i.takeUntil(e[c])};vara=function(){functione(e,t,r){this.elementRef=e,this.viewportService=t,this.platformId=r,this.preRender=!0,this.oneTime=!1,this.inViewport=newn.EventEmitter}returne.prototype.ngOnInit=function(){vart=this;r.isPlatformBrowser(this.platformId)?this.oneTime?this.viewportService.observe(this.elementRef.nativeElement).pipe(p(this),i.filter(function(e){return.5<=e.intersectionRatio}),i.take(1)).subscribe(function(e){t.inViewport.emit(e)}):this.viewportService.observe(this.elementRef.nativeElement).pipe(p(this)).subscribe(function(e){t.inViewport.emit(e)}):this.preRender&&this.inViewport.emit({isIntersecting:!0,intersectionRatio:1})},e.prototype.ngOnDestroy=function(){},e.decorators=[{type:n.Directive,args:[{selector:"[aiutInViewport]"}]}],e.ctorParameters=function(){return[{type:n.ElementRef},{type:s},{type:Object,decorators:[{type:n.Inject,args:[n.PLATFORM_ID]}]}]},e.propDecorators={preRender:[{type:n.Input}],oneTime:[{type:n.Input}],inViewport:[{type:n.Output}]},e}(),u=function(){functione(){}returne.decorators=[{type:n.NgModule,args:[{imports:[r.CommonModule],declarations:[a,t],providers:[s],exports:[a,t]}]}],e}();e.AitpUtilsModule=u,e.InViewportComponent=t,e.InViewportDirective=a,e.untilDestroy=p,e.ViewportService=s,e.ɵb=t,e.ɵa=a,e.ɵc=s,Object.defineProperty(e,"__esModule",{value:!0})});
"import {Observable} from 'rxjs';\r\nimport {takeUntil} from 'rxjs/operators';\r\nimport { MonoTypeOperatorFunction } from 'rxjs/interfaces';\r\n\r\n// create a symbol identify the observable I add to\r\n// the component so it doesn't conflict with anything.\r\n// I need this so I'm able to add the desired behaviour to the component.\r\nexport const destroy$ = 'destroy$';\r\n\r\n/**\r\n * An operator that takes until destroy it takes a components this a parameter\r\n * returns a pipeable RxJS operator.\r\n */\r\nexport const untilDestroy = <T>(component: any): MonoTypeOperatorFunction<T> => {\r\n if (component[destroy$] === undefined) {\r\n // only hookup each component once.\r\n addDestroyObservableToComponent(component);\r\n }\r\n\r\n // pipe in the takeUntil destroy$ and return the source unaltered\r\n return takeUntil<T>(component[destroy$]);\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function addDestroyObservableToComponent(component: any) {\r\n component[destroy$] = new Observable<void>(observer => {\r\n // keep track of the original destroy function,\r\n // the user might do something in there\r\n const orignalDestroy = component.ngOnDestroy;\r\n if (orignalDestroy == null) {\r\n // Angular does not support dynamic added destroy methods\r\n // so make sure there is one.\r\n throw new Error('untilDestroy operator needs the component to have an ngOnDestroy method');\r\n }\r\n // replace the ngOndestroy\r\n component.ngOnDestroy = () => {\r\n // fire off the destroy observable\r\n observer.next();\r\n // complete the observable\r\n observer.complete();\r\n // and at last, call the original destroy\r\n orignalDestroy.call(component);\r\n };\r\n // return cleanup function.\r\n return (_: any) => (component[destroy$] = undefined);\r\n });\r\n}\r\n",
"import {Directive, ElementRef, EventEmitter, Inject, Input, OnDestroy, OnInit, Output, PLATFORM_ID,} from '@angular/core';\r\nimport {isPlatformBrowser} from '@angular/common';\r\nimport {filter, take} from 'rxjs/operators';\r\nimport {ViewportService} from '../services';\r\nimport {untilDestroy} from '../operators';\r\n\r\n@Directive({\r\n selector: '[aiutInViewport]',\r\n})\r\nexport class InViewportDirective implements OnInit, OnDestroy {\r\n @Input() public preRender = true;\r\n @Input() public oneTime = false;\r\n @Output() readonly inViewport = new EventEmitter<Partial<IntersectionObserverEntry>>();\r\n\r\n constructor(\r\n private readonly elementRef: ElementRef,\r\n private viewportService: ViewportService,\r\n @Inject(PLATFORM_ID) private platformId: Object,\r\n ) {\r\n }\r\n\r\n public ngOnInit() {\r\n if (isPlatformBrowser(this.platformId)) {\r\n if (this.oneTime) {\r\n this.viewportService\r\n .observe(this.elementRef.nativeElement)\r\n .pipe(\r\n untilDestroy(this),\r\n filter(entry => entry.intersectionRatio >= 0.5),\r\n take(1),\r\n )\r\n .subscribe((entry: IntersectionObserverEntry) => {\r\n this.inViewport.emit(entry);\r\n });\r\n } else {\r\n this.viewportService\r\n .observe(this.elementRef.nativeElement)\r\n .pipe(untilDestroy(this))\r\n .subscribe((entry: IntersectionObserverEntry) => {\r\n this.inViewport.emit(entry);\r\n });\r\n }\r\n } else {\r\n if (this.preRender) {\r\n this.inViewport.emit({isIntersecting: true, intersectionRatio: 1});\r\n }\r\n }\r\n }\r\n\r\n ngOnDestroy() {\r\n }\r\n}\r\n",
"import {Observable} from 'rxjs';\r\nimport {takeUntil} from 'rxjs/operators';\r\nimport {MonoTypeOperatorFunction} from 'rxjs/interfaces';\r\n\r\n// create a symbol identify the observable I add to\r\n// the component so it doesn't conflict with anything.\r\n// I need this so I'm able to add the desired behaviour to the component.\r\nconst destroy$ = 'destroy$';\r\n\r\n/**\r\n * An operator that takes until destroy it takes a components this a parameter\r\n * returns a pipeable RxJS operator.\r\n */\r\nexport const untilDestroy = <T>(component: any): MonoTypeOperatorFunction<T> => {\r\n if (component[destroy$] === undefined) {\r\n // only hookup each component once.\r\n addDestroyObservableToComponent(component);\r\n }\r\n\r\n // pipe in the takeUntil destroy$ and return the source unaltered\r\n return takeUntil<T>(component[destroy$]);\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nfunction addDestroyObservableToComponent(component: any) {\r\n component[destroy$] = new Observable<void>(observer => {\r\n // keep track of the original destroy function,\r\n // the user might do something in there\r\n const orignalDestroy = component.ngOnDestroy;\r\n if (orignalDestroy == null) {\r\n // Angular does not support dynamic added destroy methods\r\n // so make sure there is one.\r\n throw new Error('untilDestroy operator needs the component to have an ngOnDestroy method');\r\n }\r\n // replace the ngOndestroy\r\n component.ngOnDestroy = () => {\r\n // fire off the destroy observable\r\n observer.next();\r\n // complete the observable\r\n observer.complete();\r\n // and at last, call the original destroy\r\n orignalDestroy.call(component);\r\n };\r\n // return cleanup function.\r\n return (_: any) => (component[destroy$] = undefined);\r\n });\r\n}\r\n",
"import {Directive, ElementRef, EventEmitter, Inject, Input, OnDestroy, OnInit, Output, PLATFORM_ID} from '@angular/core';\r\nimport {isPlatformBrowser} from '@angular/common';\r\nimport {filter, take} from 'rxjs/operators';\r\nimport {ViewportService} from '../services';\r\nimport {untilDestroy} from '../operators';\r\n\r\n@Directive({\r\n selector: '[aiutInViewport]',\r\n})\r\nexport class InViewportDirective implements OnInit, OnDestroy {\r\n @Input() public preRender = true;\r\n @Input() public oneTime = false;\r\n @Output() readonly inViewport = new EventEmitter<Partial<MyIntersectionObserverEntry>>();\r\n\r\n constructor(\r\n private readonly elementRef: ElementRef,\r\n private viewportService: ViewportService,\r\n @Inject(PLATFORM_ID) private platformId: Object,\r\n ) {\r\n }\r\n\r\n public ngOnInit() {\r\n if (isPlatformBrowser(this.platformId)) {\r\n if (this.oneTime) {\r\n this.viewportService\r\n .observe(this.elementRef.nativeElement)\r\n .pipe(\r\n untilDestroy(this),\r\n filter(entry => entry.intersectionRatio >= 0.5),\r\n take(1),\r\n )\r\n .subscribe((entry: MyIntersectionObserverEntry) => {\r\n this.inViewport.emit(entry);\r\n });\r\n } else {\r\n this.viewportService\r\n .observe(this.elementRef.nativeElement)\r\n .pipe(untilDestroy(this))\r\n .subscribe((entry: MyIntersectionObserverEntry) => {\r\n this.inViewport.emit(entry);\r\n });\r\n }\r\n } else {\r\n if (this.preRender) {\r\n this.inViewport.emit({isIntersecting: true, intersectionRatio: 1});\r\n }\r\n }\r\n }\r\n\r\n ngOnDestroy() {\r\n }\r\n}\r\n\r\nexport interface MyIntersectionObserverEntry extends IntersectionObserverEntry {\r\n readonly isIntersecting: boolean;\r\n}\r\n",
"import {NgModule} from '@angular/core';\r\nimport {CommonModule} from '@angular/common';\r\n\r\nimport * as Components from './components';\r\nimport * as Directives from './directives';\r\nimport * as Services from './services';\r\n\r\n@NgModule({\r\n imports: [CommonModule],\r\n declarations: [Directives.InViewportDirective, Components.InViewportComponent],\r\n providers: [Services.ViewportService],\r\n exports: [Directives.InViewportDirective, Components.InViewportComponent]\r\n})\r\nexport class AitpUtilsModule { }\r\n"
"import {Observable} from 'rxjs';\r\nimport {takeUntil} from 'rxjs/operators';\r\nimport { MonoTypeOperatorFunction } from 'rxjs/interfaces';\r\n\r\n// create a symbol identify the observable I add to\r\n// the component so it doesn't conflict with anything.\r\n// I need this so I'm able to add the desired behaviour to the component.\r\nexport const destroy$ = 'destroy$';\r\n\r\n/**\r\n * An operator that takes until destroy it takes a components this a parameter\r\n * returns a pipeable RxJS operator.\r\n */\r\nexport const untilDestroy = <T>(component: any): MonoTypeOperatorFunction<T> => {\r\n if (component[destroy$] === undefined) {\r\n // only hookup each component once.\r\n addDestroyObservableToComponent(component);\r\n }\r\n\r\n // pipe in the takeUntil destroy$ and return the source unaltered\r\n return takeUntil<T>(component[destroy$]);\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function addDestroyObservableToComponent(component: any) {\r\n component[destroy$] = new Observable<void>(observer => {\r\n // keep track of the original destroy function,\r\n // the user might do something in there\r\n const orignalDestroy = component.ngOnDestroy;\r\n if (orignalDestroy == null) {\r\n // Angular does not support dynamic added destroy methods\r\n // so make sure there is one.\r\n throw new Error('untilDestroy operator needs the component to have an ngOnDestroy method');\r\n }\r\n // replace the ngOndestroy\r\n component.ngOnDestroy = () => {\r\n // fire off the destroy observable\r\n observer.next();\r\n // complete the observable\r\n observer.complete();\r\n // and at last, call the original destroy\r\n orignalDestroy.call(component);\r\n };\r\n // return cleanup function.\r\n return (_: any) => (component[destroy$] = undefined);\r\n });\r\n}\r\n",
"import {Directive, ElementRef, EventEmitter, Inject, Input, OnDestroy, OnInit, Output, PLATFORM_ID,} from '@angular/core';\r\nimport {isPlatformBrowser} from '@angular/common';\r\nimport {filter, take} from 'rxjs/operators';\r\nimport {ViewportService} from '../services';\r\nimport {untilDestroy} from '../operators';\r\n\r\n@Directive({\r\n selector: '[aiutInViewport]',\r\n})\r\nexport class InViewportDirective implements OnInit, OnDestroy {\r\n @Input() public preRender = true;\r\n @Input() public oneTime = false;\r\n @Output() readonly inViewport = new EventEmitter<Partial<IntersectionObserverEntry>>();\r\n\r\n constructor(\r\n private readonly elementRef: ElementRef,\r\n private viewportService: ViewportService,\r\n @Inject(PLATFORM_ID) private platformId: Object,\r\n ) {\r\n }\r\n\r\n public ngOnInit() {\r\n if (isPlatformBrowser(this.platformId)) {\r\n if (this.oneTime) {\r\n this.viewportService\r\n .observe(this.elementRef.nativeElement)\r\n .pipe(\r\n untilDestroy(this),\r\n filter(entry => entry.intersectionRatio >= 0.5),\r\n take(1),\r\n )\r\n .subscribe((entry: IntersectionObserverEntry) => {\r\n this.inViewport.emit(entry);\r\n });\r\n } else {\r\n this.viewportService\r\n .observe(this.elementRef.nativeElement)\r\n .pipe(untilDestroy(this))\r\n .subscribe((entry: IntersectionObserverEntry) => {\r\n this.inViewport.emit(entry);\r\n });\r\n }\r\n } else {\r\n if (this.preRender) {\r\n this.inViewport.emit({isIntersecting: true, intersectionRatio: 1});\r\n }\r\n }\r\n }\r\n\r\n ngOnDestroy() {\r\n }\r\n}\r\n",
"import {Observable} from 'rxjs';\r\nimport {takeUntil} from 'rxjs/operators';\r\nimport {MonoTypeOperatorFunction} from 'rxjs/interfaces';\r\n\r\n// create a symbol identify the observable I add to\r\n// the component so it doesn't conflict with anything.\r\n// I need this so I'm able to add the desired behaviour to the component.\r\nconst destroy$ = 'destroy$';\r\n\r\n/**\r\n * An operator that takes until destroy it takes a components this a parameter\r\n * returns a pipeable RxJS operator.\r\n */\r\nexport const untilDestroy = <T>(component: any): MonoTypeOperatorFunction<T> => {\r\n if (component[destroy$] === undefined) {\r\n // only hookup each component once.\r\n addDestroyObservableToComponent(component);\r\n }\r\n\r\n // pipe in the takeUntil destroy$ and return the source unaltered\r\n return takeUntil<T>(component[destroy$]);\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nfunction addDestroyObservableToComponent(component: any) {\r\n component[destroy$] = new Observable<void>(observer => {\r\n // keep track of the original destroy function,\r\n // the user might do something in there\r\n const orignalDestroy = component.ngOnDestroy;\r\n if (orignalDestroy == null) {\r\n // Angular does not support dynamic added destroy methods\r\n // so make sure there is one.\r\n throw new Error('untilDestroy operator needs the component to have an ngOnDestroy method');\r\n }\r\n // replace the ngOndestroy\r\n component.ngOnDestroy = () => {\r\n // fire off the destroy observable\r\n observer.next();\r\n // complete the observable\r\n observer.complete();\r\n // and at last, call the original destroy\r\n orignalDestroy.call(component);\r\n };\r\n // return cleanup function.\r\n return (_: any) => (component[destroy$] = undefined);\r\n });\r\n}\r\n",
"import {Directive, ElementRef, EventEmitter, Inject, Input, OnDestroy, OnInit, Output, PLATFORM_ID} from '@angular/core';\r\nimport {isPlatformBrowser} from '@angular/common';\r\nimport {filter, take} from 'rxjs/operators';\r\nimport {ViewportService} from '../services';\r\nimport {untilDestroy} from '../operators';\r\n\r\n@Directive({\r\n selector: '[aiutInViewport]',\r\n})\r\nexport class InViewportDirective implements OnInit, OnDestroy {\r\n @Input() public preRender = true;\r\n @Input() public oneTime = false;\r\n @Output() readonly inViewport = new EventEmitter<Partial<MyIntersectionObserverEntry>>();\r\n\r\n constructor(\r\n private readonly elementRef: ElementRef,\r\n private viewportService: ViewportService,\r\n @Inject(PLATFORM_ID) private platformId: Object,\r\n ) {\r\n }\r\n\r\n public ngOnInit() {\r\n if (isPlatformBrowser(this.platformId)) {\r\n if (this.oneTime) {\r\n this.viewportService\r\n .observe(this.elementRef.nativeElement)\r\n .pipe(\r\n untilDestroy(this),\r\n filter(entry => entry.intersectionRatio >= 0.5),\r\n take(1),\r\n )\r\n .subscribe((entry: MyIntersectionObserverEntry) => {\r\n this.inViewport.emit(entry);\r\n });\r\n } else {\r\n this.viewportService\r\n .observe(this.elementRef.nativeElement)\r\n .pipe(untilDestroy(this))\r\n .subscribe((entry: MyIntersectionObserverEntry) => {\r\n this.inViewport.emit(entry);\r\n });\r\n }\r\n } else {\r\n if (this.preRender) {\r\n this.inViewport.emit({isIntersecting: true, intersectionRatio: 1});\r\n }\r\n }\r\n }\r\n\r\n ngOnDestroy() {\r\n }\r\n}\r\n\r\nexport interface MyIntersectionObserverEntry extends IntersectionObserverEntry {\r\n readonly isIntersecting: boolean;\r\n}\r\n",
"import {NgModule} from '@angular/core';\r\nimport {CommonModule} from '@angular/common';\r\n\r\nimport * as Components from './components';\r\nimport * as Directives from './directives';\r\nimport * as Services from './services';\r\n\r\n@NgModule({\r\n imports: [CommonModule],\r\n declarations: [Directives.InViewportDirective, Components.InViewportComponent],\r\n providers: [Services.ViewportService],\r\n exports: [Directives.InViewportDirective, Components.InViewportComponent]\r\n})\r\nexport class AitpUtilsModule { }\r\n"
"import {Observable} from 'rxjs';\r\nimport {takeUntil} from 'rxjs/operators';\r\nimport { MonoTypeOperatorFunction } from 'rxjs/interfaces';\r\n\r\n// create a symbol identify the observable I add to\r\n// the component so it doesn't conflict with anything.\r\n// I need this so I'm able to add the desired behaviour to the component.\r\nexport const destroy$ = 'destroy$';\r\n\r\n/**\r\n * An operator that takes until destroy it takes a components this a parameter\r\n * returns a pipeable RxJS operator.\r\n */\r\nexport const untilDestroy = <T>(component: any): MonoTypeOperatorFunction<T> => {\r\n if (component[destroy$] === undefined) {\r\n // only hookup each component once.\r\n addDestroyObservableToComponent(component);\r\n }\r\n\r\n // pipe in the takeUntil destroy$ and return the source unaltered\r\n return takeUntil<T>(component[destroy$]);\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nexport function addDestroyObservableToComponent(component: any) {\r\n component[destroy$] = new Observable<void>(observer => {\r\n // keep track of the original destroy function,\r\n // the user might do something in there\r\n const orignalDestroy = component.ngOnDestroy;\r\n if (orignalDestroy == null) {\r\n // Angular does not support dynamic added destroy methods\r\n // so make sure there is one.\r\n throw new Error('untilDestroy operator needs the component to have an ngOnDestroy method');\r\n }\r\n // replace the ngOndestroy\r\n component.ngOnDestroy = () => {\r\n // fire off the destroy observable\r\n observer.next();\r\n // complete the observable\r\n observer.complete();\r\n // and at last, call the original destroy\r\n orignalDestroy.call(component);\r\n };\r\n // return cleanup function.\r\n return (_: any) => (component[destroy$] = undefined);\r\n });\r\n}\r\n",
"import {Directive, ElementRef, EventEmitter, Inject, Input, OnDestroy, OnInit, Output, PLATFORM_ID,} from '@angular/core';\r\nimport {isPlatformBrowser} from '@angular/common';\r\nimport {filter, take} from 'rxjs/operators';\r\nimport {ViewportService} from '../services';\r\nimport {untilDestroy} from '../operators';\r\n\r\n@Directive({\r\n selector: '[aiutInViewport]',\r\n})\r\nexport class InViewportDirective implements OnInit, OnDestroy {\r\n @Input() public preRender = true;\r\n @Input() public oneTime = false;\r\n @Output() readonly inViewport = new EventEmitter<Partial<IntersectionObserverEntry>>();\r\n\r\n constructor(\r\n private readonly elementRef: ElementRef,\r\n private viewportService: ViewportService,\r\n @Inject(PLATFORM_ID) private platformId: Object,\r\n ) {\r\n }\r\n\r\n public ngOnInit() {\r\n if (isPlatformBrowser(this.platformId)) {\r\n if (this.oneTime) {\r\n this.viewportService\r\n .observe(this.elementRef.nativeElement)\r\n .pipe(\r\n untilDestroy(this),\r\n filter(entry => entry.intersectionRatio >= 0.5),\r\n take(1),\r\n )\r\n .subscribe((entry: IntersectionObserverEntry) => {\r\n this.inViewport.emit(entry);\r\n });\r\n } else {\r\n this.viewportService\r\n .observe(this.elementRef.nativeElement)\r\n .pipe(untilDestroy(this))\r\n .subscribe((entry: IntersectionObserverEntry) => {\r\n this.inViewport.emit(entry);\r\n });\r\n }\r\n } else {\r\n if (this.preRender) {\r\n this.inViewport.emit({isIntersecting: true, intersectionRatio: 1});\r\n }\r\n }\r\n }\r\n\r\n ngOnDestroy() {\r\n }\r\n}\r\n",
"import {Observable} from 'rxjs';\r\nimport {takeUntil} from 'rxjs/operators';\r\nimport {MonoTypeOperatorFunction} from 'rxjs/interfaces';\r\n\r\n// create a symbol identify the observable I add to\r\n// the component so it doesn't conflict with anything.\r\n// I need this so I'm able to add the desired behaviour to the component.\r\nconst destroy$ = 'destroy$';\r\n\r\n/**\r\n * An operator that takes until destroy it takes a components this a parameter\r\n * returns a pipeable RxJS operator.\r\n */\r\nexport const untilDestroy = <T>(component: any): MonoTypeOperatorFunction<T> => {\r\n if (component[destroy$] === undefined) {\r\n // only hookup each component once.\r\n addDestroyObservableToComponent(component);\r\n }\r\n\r\n // pipe in the takeUntil destroy$ and return the source unaltered\r\n return takeUntil<T>(component[destroy$]);\r\n};\r\n\r\n/**\r\n * @internal\r\n */\r\nfunction addDestroyObservableToComponent(component: any) {\r\n component[destroy$] = new Observable<void>(observer => {\r\n // keep track of the original destroy function,\r\n // the user might do something in there\r\n const orignalDestroy = component.ngOnDestroy;\r\n if (orignalDestroy == null) {\r\n // Angular does not support dynamic added destroy methods\r\n // so make sure there is one.\r\n throw new Error('untilDestroy operator needs the component to have an ngOnDestroy method');\r\n }\r\n // replace the ngOndestroy\r\n component.ngOnDestroy = () => {\r\n // fire off the destroy observable\r\n observer.next();\r\n // complete the observable\r\n observer.complete();\r\n // and at last, call the original destroy\r\n orignalDestroy.call(component);\r\n };\r\n // return cleanup function.\r\n return (_: any) => (component[destroy$] = undefined);\r\n });\r\n}\r\n",
"import {Directive, ElementRef, EventEmitter, Inject, Input, OnDestroy, OnInit, Output, PLATFORM_ID} from '@angular/core';\r\nimport {isPlatformBrowser} from '@angular/common';\r\nimport {filter, take} from 'rxjs/operators';\r\nimport {ViewportService} from '../services';\r\nimport {untilDestroy} from '../operators';\r\n\r\n@Directive({\r\n selector: '[aiutInViewport]',\r\n})\r\nexport class InViewportDirective implements OnInit, OnDestroy {\r\n @Input() public preRender = true;\r\n @Input() public oneTime = false;\r\n @Output() readonly inViewport = new EventEmitter<Partial<MyIntersectionObserverEntry>>();\r\n\r\n constructor(\r\n private readonly elementRef: ElementRef,\r\n private viewportService: ViewportService,\r\n @Inject(PLATFORM_ID) private platformId: Object,\r\n ) {\r\n }\r\n\r\n public ngOnInit() {\r\n if (isPlatformBrowser(this.platformId)) {\r\n if (this.oneTime) {\r\n this.viewportService\r\n .observe(this.elementRef.nativeElement)\r\n .pipe(\r\n untilDestroy(this),\r\n filter(entry => entry.intersectionRatio >= 0.5),\r\n take(1),\r\n )\r\n .subscribe((entry: MyIntersectionObserverEntry) => {\r\n this.inViewport.emit(entry);\r\n });\r\n } else {\r\n this.viewportService\r\n .observe(this.elementRef.nativeElement)\r\n .pipe(untilDestroy(this))\r\n .subscribe((entry: MyIntersectionObserverEntry) => {\r\n this.inViewport.emit(entry);\r\n });\r\n }\r\n } else {\r\n if (this.preRender) {\r\n this.inViewport.emit({isIntersecting: true, intersectionRatio: 1});\r\n }\r\n }\r\n }\r\n\r\n ngOnDestroy() {\r\n }\r\n}\r\n\r\nexport interface MyIntersectionObserverEntry extends IntersectionObserverEntry {\r\n readonly isIntersecting: boolean;\r\n}\r\n",
"import {NgModule} from '@angular/core';\r\nimport {CommonModule} from '@angular/common';\r\n\r\nimport * as Components from './components';\r\nimport * as Directives from './directives';\r\nimport * as Services from './services';\r\n\r\n@NgModule({\r\n imports: [CommonModule],\r\n declarations: [Directives.InViewportDirective, Components.InViewportComponent],\r\n providers: [Services.ViewportService],\r\n exports: [Directives.InViewportDirective, Components.InViewportComponent]\r\n})\r\nexport class AitpUtilsModule { }\r\n"