{"version":3,"file":"primeng-defer.umd.js","sources":["../../src/app/components/defer/defer.ts","../../src/app/components/defer/primeng-defer.ts"],"sourcesContent":["import {NgModule,Directive,ElementRef,AfterViewInit,OnDestroy,TemplateRef,EmbeddedViewRef,\n ViewContainerRef,Renderer2,EventEmitter,Output,ContentChild} from '@angular/core';\nimport {CommonModule} from '@angular/common';\n\n@Directive({\n selector: '[pDefer]'\n})\nexport class DeferredLoader implements AfterViewInit,OnDestroy {\n \n @Output() onLoad: EventEmitter = new EventEmitter();\n \n @ContentChild(TemplateRef) template: TemplateRef;\n \n documentScrollListener: Function;\n \n view: EmbeddedViewRef;\n \n constructor(public el: ElementRef, public renderer: Renderer2, public viewContainer: ViewContainerRef) {}\n \n ngAfterViewInit() {\n if (this.shouldLoad()) {\n this.load();\n }\n \n if (!this.isLoaded()) {\n this.documentScrollListener = this.renderer.listen('window', 'scroll', () => {\n if (this.shouldLoad()) {\n this.load();\n this.documentScrollListener();\n this.documentScrollListener = null;\n }\n });\n }\n }\n \n shouldLoad(): boolean {\n if (this.isLoaded()) {\n return false;\n }\n else {\n let rect = this.el.nativeElement.getBoundingClientRect();\n let docElement = document.documentElement;\n let winHeight = docElement.clientHeight;\n \n return (winHeight >= rect.top);\n }\n }\n \n load(): void { \n this.view = this.viewContainer.createEmbeddedView(this.template);\n this.onLoad.emit();\n }\n \n isLoaded() {\n return this.view != null;\n }\n \n ngOnDestroy() {\n this.view = null;\n \n if (this.documentScrollListener) {\n this.documentScrollListener();\n }\n }\n}\n\n@NgModule({\n imports: [CommonModule],\n exports: [DeferredLoader],\n declarations: [DeferredLoader]\n})\nexport class DeferModule { }","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":["EventEmitter","Directive","ElementRef","Renderer2","ViewContainerRef","Output","ContentChild","TemplateRef","NgModule","CommonModule"],"mappings":";;;;;;;QAiBI,wBAAmB,EAAc,EAAS,QAAmB,EAAS,aAA+B;YAAlF,OAAE,GAAF,EAAE,CAAY;Y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