UNPKG

ng-zorro-antd

Version:

An enterprise-class UI components based on Ant Design and Angular

2 lines 3.22 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/cdk/platform"),require("@angular/common"),require("@angular/core"),require("ng-zorro-antd/core"),require("rxjs"),require("rxjs/operators")):"function"==typeof define&&define.amd?define("ng-zorro-antd/back-top",["exports","@angular/cdk/platform","@angular/common","@angular/core","ng-zorro-antd/core","rxjs","rxjs/operators"],e):e((t["ng-zorro-antd"]=t["ng-zorro-antd"]||{},t["ng-zorro-antd"]["back-top"]={}),t.ng.cdk.platform,t.ng.common,t.ng.core,t["ng-zorro-antd"].core,t.rxjs,t.rxjs.operators)}(this,function(t,e,o,n,r,i,s){"use strict";var c=function(){function t(t,e,o,r){this.scrollSrv=t,this.doc=e,this.platform=o,this.cd=r,this.scroll$=null,this.target=null,this.visible=!1,this._visibilityHeight=400,this.nzClick=new n.EventEmitter}return Object.defineProperty(t.prototype,"nzVisibilityHeight",{get:function(){return this._visibilityHeight},set:function(t){this._visibilityHeight=r.toNumber(t,400)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"nzTarget",{set:function(t){this.target="string"==typeof t?this.doc.querySelector(t):t,this.registerScrollEvent()},enumerable:!0,configurable:!0}),t.prototype.ngOnInit=function(){this.scroll$||this.registerScrollEvent()},t.prototype.clickBackTop=function(){this.scrollSrv.scrollTo(this.getTarget(),0),this.nzClick.emit(!0)},t.prototype.getTarget=function(){return this.target||window},t.prototype.handleScroll=function(){this.visible!==this.scrollSrv.getScroll(this.getTarget())>this.nzVisibilityHeight&&(this.visible=!this.visible,this.cd.markForCheck())},t.prototype.removeListen=function(){this.scroll$&&this.scroll$.unsubscribe()},t.prototype.registerScrollEvent=function(){var t=this;this.platform.isBrowser&&(this.removeListen(),this.handleScroll(),this.scroll$=i.fromEvent(this.getTarget(),"scroll").pipe(s.throttleTime(50),s.distinctUntilChanged()).subscribe(function(){return t.handleScroll()}))},t.prototype.ngOnDestroy=function(){this.removeListen()},t.decorators=[{type:n.Component,args:[{selector:"nz-back-top",exportAs:"nzBackTop",animations:[r.fadeMotion],template:'<div class="ant-back-top" (click)="clickBackTop()" @fadeMotion *ngIf="visible">\n <ng-template #defaultContent>\n <div class="ant-back-top-content">\n <div class="ant-back-top-icon"></div>\n </div>\n </ng-template>\n <ng-template [ngTemplateOutlet]="nzTemplate || defaultContent"></ng-template>\n</div>',changeDetection:n.ChangeDetectionStrategy.OnPush,encapsulation:n.ViewEncapsulation.None,preserveWhitespaces:!1}]}],t.ctorParameters=function(){return[{type:r.NzScrollService},{type:undefined,decorators:[{type:n.Inject,args:[o.DOCUMENT]}]},{type:e.Platform},{type:n.ChangeDetectorRef}]},t.propDecorators={nzTemplate:[{type:n.Input}],nzVisibilityHeight:[{type:n.Input}],nzTarget:[{type:n.Input}],nzClick:[{type:n.Output}]},t}(),l=function(){function t(){}return t.decorators=[{type:n.NgModule,args:[{declarations:[c],exports:[c],imports:[o.CommonModule],providers:[r.SCROLL_SERVICE_PROVIDER]}]}],t}();t.NzBackTopComponent=c,t.NzBackTopModule=l,Object.defineProperty(t,"__esModule",{value:!0})}); //# sourceMappingURL=ng-zorro-antd-back-top.umd.min.js.map