{"version":3,"sources":["../../src/app/components/scrolltop/scrolltop.ts"],"names":["ScrollTop","el","cd","this","target","threshold","icon","behavior","showTransitionOptions","hideTransitionOptions","visible","prototype","ngOnInit","bindDocumentScrollListener","bindParentScrollListener","onClick","window","nativeElement","parentElement","scroll","top","onEnter","children","style","zIndex","DomHandler","generateZIndex","checkVisibility","scrollY","markForCheck","_this","scrollListener","scrollTop","addEventListener","getWindowScrollTop","unbindParentScrollListener","removeEventListener","unbindDocumentScrollListener","containerClass","p-scrolltop p-link p-component","p-scrolltop-sticky","ngOnDestroy","Component","args","selector","template","changeDetection","ChangeDetectionStrategy","OnPush","encapsulation","ViewEncapsulation","None","animations","trigger","state","opacity","transition","animate","ElementRef","ChangeDetectorRef","Input","NgModule","imports","CommonModule","exports","declarations"],"mappings":"oiBAmDI,SAAAA,EAAmBC,EAAwBC,GAAxBC,KAAAF,GAAAA,EAAwBE,KAAAD,GAAAA,EAhBlCC,KAAAC,OAAiB,SAEjBD,KAAAE,UAAoB,IAEpBF,KAAAG,KAAe,mBAEfH,KAAAI,SAAmB,SAEnBJ,KAAAK,sBAAgC,OAEhCL,KAAAM,sBAAgC,OAIzCN,KAAAO,SAAmB,SAInBV,EAAAW,UAAAC,SAAA,WACwB,WAAhBT,KAAKC,OACLD,KAAKU,6BACgB,WAAhBV,KAAKC,QACVD,KAAKW,4BAGbd,EAAAW,UAAAI,QAAA,YACwC,WAAhBZ,KAAKC,OAAsBY,OAASb,KAAKF,GAAGgB,cAAcC,eAC/DC,OAAO,CAClBC,IAAK,EACLb,SAAUJ,KAAKI,YAIvBP,EAAAW,UAAAU,QAAA,WACIlB,KAAKF,GAAGgB,cAAcK,SAAS,GAAGC,MAAMC,OAASC,EAAAA,WAAWC,kBAGhE1B,EAAAW,UAAAgB,gBAAA,SAAgBC,GACRA,EAAUzB,KAAKE,UACfF,KAAKO,SAAU,EAEfP,KAAKO,SAAU,EAEnBP,KAAKD,GAAG2B,gBAGZ7B,EAAAW,UAAAG,yBAAA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A,EAAAA,oBAEAA,EAAAA,wBAEAA,EAAAA,qCAEAA,EAAAA,qCAEAA,EAAAA,eAuFL,iCALCC,EAAAA,SAAQlB,KAAA,CAAC,CACNmB,QAAS,CAACC,EAAAA,cACVC,QAAS,CAAChE,GACViE,aAAc,CAACjE","sourcesContent":["import { NgModule, Component, ChangeDetectionStrategy, ViewEncapsulation, Input, OnInit, OnDestroy, ElementRef, ChangeDetectorRef} from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { animate, state, style, transition, trigger } from '@angular/animations';\nimport { DomHandler } from 'primeng/dom';\n\n@Component({\n selector: 'p-scrollTop',\n template: `\n \n `,\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n styleUrls: ['./scrolltop.css'],\n animations: [\n trigger('animation', [\n state('void', style({\n opacity: 0\n })),\n state('open', style({\n opacity: 1\n })),\n transition('void => open', animate('{{showTransitionParams}}')),\n transition('open => void', animate('{{hideTransitionParams}}')),\n ])\n ]\n})\nexport class ScrollTop implements OnInit, OnDestroy {\n\n @Input() styleClass: string;\n\n @Input() style: any;\n\n @Input() target: string = \"window\";\n \n @Input() threshold: number = 400;\n\n @Input() icon: string = \"pi pi-chevron-up\";\n\n @Input() behavior: string = \"smooth\";\n \n @Input() showTransitionOptions: string = '.15s';\n\n @Input() hideTransitionOptions: string = '.15s';\n\n scrollListener: any;\n \n visible: boolean = false;\n\n constructor(public el: ElementRef, private cd: ChangeDetectorRef) { }\n\n ngOnInit() {\n if (this.target === 'window')\n this.bindDocumentScrollListener();\n else if (this.target === 'parent')\n this.bindParentScrollListener();\n }\n\n onClick() {\n let scrollElement = this.target === 'window' ? window : this.el.nativeElement.parentElement;\n scrollElement.scroll({\n top: 0, \n behavior: this.behavior\n });\n }\n\n onEnter() {\n this.el.nativeElement.children[0].style.zIndex = DomHandler.generateZIndex();\n }\n\n checkVisibility(scrollY) {\n if (scrollY > this.threshold)\n this.visible = true;\n else\n this.visible = false;\n\n this.cd.markForCheck();\n }\n\n bindParentScrollListener() {\n this.scrollListener = () => {\n\n this.checkVisibility(this.el.nativeElement.parentElement.scrollTop);\n };\n \n this.el.nativeElement.parentElement.addEventListener('scroll', this.scrollListener);\n }\n\n bindDocumentScrollListener() {\n this.scrollListener = () => {\n this.checkVisibility(DomHandler.getWindowScrollTop());\n };\n \n window.addEventListener('scroll', this.scrollListener);\n }\n\n unbindParentScrollListener() {\n if (this.scrollListener) {\n this.el.nativeElement.parentElement.removeEventListener('scroll', this.scrollListener);\n this.scrollListener = null;\n }\n }\n\n unbindDocumentScrollListener() {\n if (this.scrollListener) {\n window.removeEventListener('scroll', this.scrollListener);\n this.scrollListener = null;\n }\n }\n\n containerClass() {\n return {\n 'p-scrolltop p-link p-component': true,\n 'p-scrolltop-sticky': this.target !== 'window'\n };\n }\n\n ngOnDestroy() {\n if (this.target === 'window')\n this.unbindDocumentScrollListener();\n else if (this.target === 'parent')\n this.unbindParentScrollListener();\n }\n}\n\n@NgModule({\n imports: [CommonModule],\n exports: [ScrollTop],\n declarations: [ScrollTop]\n})\nexport class ScrollTopModule { }\n"]}