ng-zorro-antd
Version:
An enterprise-class UI components based on Ant Design and Angular
2 lines • 3.19 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/cdk/platform"),require("rxjs"),require("rxjs/operators"),require("@angular/common"),require("@angular/core"),require("ng-zorro-antd/core")):"function"==typeof define&&define.amd?define("ng-zorro-antd/back-top",["exports","@angular/cdk/platform","rxjs","rxjs/operators","@angular/common","@angular/core","ng-zorro-antd/core"],e):e((t["ng-zorro-antd"]=t["ng-zorro-antd"]||{},t["ng-zorro-antd"]["back-top"]={}),t.ng.cdk.platform,t.rxjs,t.rxjs.operators,t.ng.common,t.ng.core,t["ng-zorro-antd"].core)}(this,function(t,e,o,r,n,i,s){"use strict";var c=(Object.defineProperty(l.prototype,"nzVisibilityHeight",{get:function(){return this._visibilityHeight},set:function(t){this._visibilityHeight=s.toNumber(t,400)},enumerable:!0,configurable:!0}),Object.defineProperty(l.prototype,"nzTarget",{set:function(t){this.target="string"==typeof t?this.doc.querySelector(t):t,this.registerScrollEvent()},enumerable:!0,configurable:!0}),l.prototype.ngOnInit=function(){this.scroll$||this.registerScrollEvent()},l.prototype.clickBackTop=function(){this.scrollSrv.scrollTo(this.getTarget(),0),this.nzClick.emit(!0)},l.prototype.getTarget=function(){return this.target||window},l.prototype.handleScroll=function(){this.visible!==this.scrollSrv.getScroll(this.getTarget())>this.nzVisibilityHeight&&(this.visible=!this.visible,this.cd.markForCheck())},l.prototype.removeListen=function(){this.scroll$&&this.scroll$.unsubscribe()},l.prototype.registerScrollEvent=function(){var t=this;this.platform.isBrowser&&(this.removeListen(),this.handleScroll(),this.scroll$=o.fromEvent(this.getTarget(),"scroll").pipe(r.throttleTime(50),r.distinctUntilChanged()).subscribe(function(){return t.handleScroll()}))},l.prototype.ngOnDestroy=function(){this.removeListen()},l.decorators=[{type:i.Component,args:[{selector:"nz-back-top",exportAs:"nzBackTop",animations:[s.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:i.ChangeDetectionStrategy.OnPush,encapsulation:i.ViewEncapsulation.None,preserveWhitespaces:!1}]}],l.ctorParameters=function(){return[{type:s.NzScrollService},{type:undefined,decorators:[{type:i.Inject,args:[n.DOCUMENT]}]},{type:e.Platform},{type:i.ChangeDetectorRef}]},l.propDecorators={nzTemplate:[{type:i.Input}],nzVisibilityHeight:[{type:i.Input}],nzTarget:[{type:i.Input}],nzClick:[{type:i.Output}]},l);function l(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 i.EventEmitter}var a=(p.decorators=[{type:i.NgModule,args:[{declarations:[c],exports:[c],imports:[n.CommonModule],providers:[s.SCROLL_SERVICE_PROVIDER]}]}],p);function p(){}t.NzBackTopComponent=c,t.NzBackTopModule=a,Object.defineProperty(t,"__esModule",{value:!0})});
//# sourceMappingURL=ng-zorro-antd-back-top.umd.min.js.map