{"version":3,"file":"primeng-scrolltop.mjs","sources":["../../src/app/components/scrolltop/scrolltop.ts","../../src/app/components/scrolltop/primeng-scrolltop.ts"],"sourcesContent":["import { AnimationEvent, animate, state, style, transition, trigger } from '@angular/animations';\nimport { CommonModule, DOCUMENT, isPlatformBrowser } from '@angular/common';\nimport { AfterViewInit, ChangeDetectionStrategy, ChangeDetectorRef, Component, ContentChildren, ElementRef, Inject, Input, NgModule, OnDestroy, OnInit, PLATFORM_ID, QueryList, Renderer2, TemplateRef, ViewEncapsulation } from '@angular/core';\nimport { LicenseManager, PrimeNGConfig, PrimeTemplate, SharedModule } from 'primeng/api';\nimport { DomHandler } from 'primeng/dom';\nimport { ChevronUpIcon } from 'primeng/icons/chevronup';\nimport { ZIndexUtils } from 'primeng/utils';\n\n@Component({\n selector: 'p-scrollTop',\n template: `\n \n \n \n \n \n \n \n `,\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n styleUrls: ['./scrolltop.css'],\n animations: [\n trigger('animation', [\n state(\n 'void',\n style({\n opacity: 0\n })\n ),\n state(\n 'open',\n style({\n opacity: 1\n })\n ),\n transition('void => open', animate('{{showTransitionParams}}')),\n transition('open => void', animate('{{hideTransitionParams}}'))\n ])\n ],\n host: {\n class: 'p-element'\n }\n})\nexport class ScrollTop implements OnInit, OnDestroy, AfterViewInit {\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;\n\n @Input() behavior: string = 'smooth';\n\n @Input() showTransitionOptions: string = '.15s';\n\n @Input() hideTransitionOptions: string = '.15s';\n\n @ContentChildren(PrimeTemplate) templates: QueryList;\n\n iconTemplate: TemplateRef;\n\n documentScrollListener: VoidFunction | null;\n\n parentScrollListener: VoidFunction | null;\n\n visible: boolean = false;\n\n overlay: any;\n\n private window: Window;\n\n constructor(@Inject(DOCUMENT) private document: Document, @Inject(PLATFORM_ID) private platformId: any, private renderer: Renderer2, public el: ElementRef, private cd: ChangeDetectorRef, public config: PrimeNGConfig) {\n this.window = this.document.defaultView;\n }\n\n ngOnInit() {\n if (this.target === 'window') this.bindDocumentScrollListener();\n else if (this.target === 'parent') this.bindParentScrollListener();\n }\n\n ngAfterContentInit() {\n this.templates.forEach((item) => {\n switch (item.getType()) {\n case 'icon':\n this.iconTemplate = item.template;\n break;\n }\n });\n }\n\n ngAfterViewInit() {\n LicenseManager.check();\n }\n\n onClick() {\n let scrollElement = this.target === 'window' ? this.window : this.el.nativeElement.parentElement;\n scrollElement.scroll({\n top: 0,\n behavior: this.behavior\n });\n }\n\n onEnter(event: AnimationEvent) {\n switch (event.toState) {\n case 'open':\n this.overlay = event.element;\n ZIndexUtils.set('overlay', this.overlay, this.config.zIndex.overlay);\n break;\n case 'void':\n this.overlay = null;\n break;\n }\n }\n\n onLeave(event: AnimationEvent) {\n switch (event.toState) {\n case 'void':\n ZIndexUtils.clear(event.element);\n break;\n }\n }\n\n checkVisibility(scrollY) {\n if (scrollY > this.threshold) this.visible = true;\n else this.visible = false;\n\n this.cd.markForCheck();\n }\n\n bindParentScrollListener() {\n if (isPlatformBrowser(this.platformId)) {\n this.parentScrollListener = this.renderer.listen(this.el.nativeElement.parentElement, 'scroll', () => {\n this.checkVisibility(this.el.nativeElement.parentElement.scrollTop);\n });\n }\n }\n\n bindDocumentScrollListener() {\n if (isPlatformBrowser(this.platformId)) {\n this.documentScrollListener = this.renderer.listen(this.window, 'scroll', () => {\n this.checkVisibility(DomHandler.getWindowScrollTop());\n });\n }\n }\n\n unbindParentScrollListener() {\n if (this.parentScrollListener) {\n this.parentScrollListener();\n this.parentScrollListener = null;\n }\n }\n\n unbindDocumentScrollListener() {\n if (this.documentScrollListener) {\n this.documentScrollListener();\n this.documentScrollListener = 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') this.unbindDocumentScrollListener();\n else if (this.target === 'parent') this.unbindParentScrollListener();\n\n if (this.overlay) {\n ZIndexUtils.clear(this.overlay);\n this.overlay = null;\n }\n }\n}\n\n@NgModule({\n imports: [CommonModule, ChevronUpIcon, SharedModule],\n exports: [ScrollTop, SharedModule],\n declarations: [ScrollTop]\n})\nexport class ScrollTopModule {}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;;;;;;;;MAsDa,SAAS,CAAA;IA+BlB,WAAsC,CAAA,QAAkB,EAA+B,UAAe,EAAU,QAAmB,EAAS,EAAc,EAAU,EAAqB,EAAS,MAAqB,EAAA;AAAjL,QAAA,IAAQ,CAAA,QAAA,GAAR,QAAQ,CAAU;AAA+B,QAAA,IAAU,CAAA,UAAA,GAAV,UAAU,CAAK;AAAU,QAAA,IAAQ,CAAA,QAAA,GAAR,QAAQ,CAAW;AAAS,QAAA,IAAE,CAAA,EAAA,GAAF,EAAE,CAAY;AAAU,QAAA,IAAE,CAAA,EAAA,GAAF,EAAE,CAAmB;AAAS,QAAA,IAAM,CAAA,MAAA,GAAN,MAAM,CAAe;AA1B9M,QAAA,IAAM,CAAA,MAAA,GAAW,QAAQ,CAAC;AAE1B,QAAA,IAAS,CAAA,SAAA,GAAW,GAAG,CAAC;AAIxB,QAAA,IAAQ,CAAA,QAAA,GAAW,QAAQ,CAAC;AAE5B,QAAA,IAAqB,CAAA,qBAAA,GAAW,MAAM,CAAC;AAEvC,QAAA,IAAqB,CAAA,qBAAA,GAAW,MAAM,CAAC;AAUhD,QAAA,IAAO,CAAA,OAAA,GAAY,KAAK,CAAC;QAOrB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC;KAC3C;IAED,QAAQ,GAAA;AACJ,QAAA,IAAI,IAAI,CAAC,MAAM,KAAK,QAAQ;YAAE,IAAI,CAAC,0BAA0B,EAAE,CAAC;AAC3D,aAAA,IAAI,IAAI,CAAC,MAAM,KAAK,QA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