primeng
Version:
[](https://opensource.org/licenses/MIT) [](https://badge.fury.io/js/primeng) [{"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("@angular/common"),require("@angular/animations"),require("primeng/dom")):"function"==typeof define&&define.amd?define("primeng/scrolltop",["exports","@angular/core","@angular/common","@angular/animations","primeng/dom"],e):e(((t="undefined"!=typeof globalThis?globalThis:t||self).primeng=t.primeng||{},t.primeng.scrolltop={}),t.ng.core,t.ng.common,t.ng.animations,t.primeng.dom)}(this,(function(t,e,n,i,o){"use strict";var s=function(){function t(t,e){this.el=t,this.cd=e,this.target="window",this.threshold=400,this.icon="pi pi-chevron-up",this.behavior="smooth",this.showTransitionOptions=".15s",this.hideTransitionOptions=".15s",this.visible=!1}return t.prototype.ngOnInit=function(){"window"===this.target?this.bindDocumentScrollListener():"parent"===this.target&&this.bindParentScrollListener()},t.prototype.onClick=function(){("window"===this.target?window:this.el.nativeElement.parentElement).scroll({top:0,behavior:this.behavior})},t.prototype.onEnter=function(){this.el.nativeElement.children[0].style.zIndex=o.DomHandler.generateZIndex()},t.prototype.checkVisibility=function(t){t>this.threshold?this.visible=!0:this.visible=!1,this.cd.markForCheck()},t.prototype.bindParentScrollListener=function(){var t=this;this.scrollListener=function(){t.checkVisibility(t.el.nativeElement.parentElement.scrollTop)},this.el.nativeElement.parentElement.addEventListener("scroll",this.scrollListener)},t.prototype.bindDocumentScrollListener=function(){var t=this;this.scrollListener=function(){t.checkVisibility(o.DomHandler.getWindowScrollTop())},window.addEventListener("scroll",this.scrollListener)},t.prototype.unbindParentScrollListener=function(){this.scrollListener&&(this.el.nativeElement.parentElement.removeEventListener("scroll",this.scrollListener),this.scrollListener=null)},t.prototype.unbindDocumentScrollListener=function(){this.scrollListener&&(window.removeEventListener("scroll",this.scrollListener),this.scrollListener=null)},t.prototype.containerClass=function(){return{"p-scrolltop p-link p-component":!0,"p-scrolltop-sticky":"window"!==this.target}},t.prototype.ngOnDestroy=function(){"window"===this.target?this.unbindDocumentScrollListener():"parent"===this.target&&this.unbindParentScrollListener()},t}();s.decorators=[{type:e.Component,args:[{selector:"p-scrollTop",template:'\n <button *ngIf="visible" [@animation]="{value: \'open\', params: {showTransitionParams: showTransitionOptions, hideTransitionParams: hideTransitionOptions}}" (@animation.start)="onEnter()"\n [ngClass]="containerClass()" (click)="onClick()" [class]="styleClass" [ngStyle]="style" type="button">\n <span [class]="icon" [ngClass]="\'p-scrolltop-icon\'"></span>\n </button>\n ',changeDetection:e.ChangeDetectionStrategy.OnPush,encapsulation:e.ViewEncapsulation.None,animations:[i.trigger("animation",[i.state("void",i.style({opacity:0})),i.state("open",i.style({opacity:1})),i.transition("void => open",i.animate("{{showTransitionParams}}")),i.transition("open => void",i.animate("{{hideTransitionParams}}"))])],styles:[".p-scrolltop{align-items:center;bottom:20px;display:flex;justify-content:center;position:fixed;right:20px}.p-scrolltop-sticky{position:sticky}.p-scrolltop-sticky.p-link{margin-left:auto}"]}]}],s.ctorParameters=function(){return[{type:e.ElementRef},{type:e.ChangeDetectorRef}]},s.propDecorators={styleClass:[{type:e.Input}],style:[{type:e.Input}],target:[{type:e.Input}],threshold:[{type:e.Input}],icon:[{type:e.Input}],behavior:[{type:e.Input}],showTransitionOptions:[{type:e.Input}],hideTransitionOptions:[{type:e.Input}]};var r=function(){};r.decorators=[{type:e.NgModule,args:[{imports:[n.CommonModule],exports:[s],declarations:[s]}]}],t.ScrollTop=s,t.ScrollTopModule=r,Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=primeng-scrolltop.umd.min.js.map