{"version":3,"file":"primeng-scrolltop.umd.js","sources":["../../src/app/components/scrolltop/scrolltop.ts","../../src/app/components/scrolltop/primeng-scrolltop.ts"],"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","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":["DomHandler","Component","ChangeDetectionStrategy","ViewEncapsulation","trigger","state","style","transition","animate","ElementRef","ChangeDetectorRef","Input","NgModule","CommonModule"],"mappings":";;;;;;;QAmDI,mBAAmB,EAAc,EAAU,EAAqB;YAA7C,OAAE,GAAF,EAAE,CAAY;YAAU,OAAE,GAAF,EAAE,CAAmB;YAhBvD,WAAM,GAAW,QAAQ,CAAC;YAE1B,cAAS,GAAW,GAAG,CAAC;YAExB,SAAI,GAAW,kBAAkB,CAAC;YAElC,aAAQ,GAAW,QAAQ,CAAC;YAE5B,0BAAqB,GAAW,MAAM,CAAC;YAEvC,0BAAqB,GAAW,MAAM,CAAC;YAIhD,YAAO,GAAY,KAAK,CAAC;SAE4C;QAErE,4BAAQ,GAAR;YACI,IAAI,IAAI,CAAC,MAAM,KAAK,QAAQ;gBACxB,IAAI,CAAC,0BAA0B,EAAE,CAAC;iBACjC,IAAI,IAAI,CAAC,MAAM,KAAK,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