ng-zorro-antd
Version:
An enterprise-class UI components based on Ant Design and Angular
2 lines • 3.61 kB
JavaScript
!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=t||self)["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,r,n,i,c){"use strict";function s(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}var l=function(){function t(t,e,o,n,i){this.nzConfigService=t,this.scrollSrv=e,this.doc=o,this.platform=n,this.cd=i,this.scroll$=null,this.target=null,this.visible=!1,this.nzClick=new r.EventEmitter}return 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(c.throttleTime(50),c.distinctUntilChanged()).subscribe(function(){return t.handleScroll()}))},t.prototype.ngOnDestroy=function(){this.removeListen()},t.decorators=[{type:r.Component,args:[{selector:"nz-back-top",exportAs:"nzBackTop",animations:[n.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:r.ChangeDetectionStrategy.OnPush,encapsulation:r.ViewEncapsulation.None,preserveWhitespaces:!1}]}],t.ctorParameters=function(){return[{type:n.NzConfigService},{type:n.NzScrollService},{type:void 0,decorators:[{type:r.Inject,args:[o.DOCUMENT]}]},{type:e.Platform},{type:r.ChangeDetectorRef}]},t.propDecorators={nzTemplate:[{type:r.Input}],nzVisibilityHeight:[{type:r.Input}],nzTarget:[{type:r.Input}],nzClick:[{type:r.Output}]},function(t,e,o,r){var n,i=arguments.length,c=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,o):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(t,e,o,r);else for(var s=t.length-1;s>=0;s--)(n=t[s])&&(c=(i<3?n(c):i>3?n(e,o,c):n(e,o))||c);i>3&&c&&Object.defineProperty(e,o,c)}([n.WithConfig(400),n.InputNumber(),s("design:type",Number)],t.prototype,"nzVisibilityHeight",void 0),t}();var a=function(){function t(){}return t.decorators=[{type:r.NgModule,args:[{declarations:[l],exports:[l],imports:[o.CommonModule,e.PlatformModule],providers:[n.SCROLL_SERVICE_PROVIDER]}]}],t}();t.NzBackTopComponent=l,t.NzBackTopModule=a,Object.defineProperty(t,"__esModule",{value:!0})});
//# sourceMappingURL=ng-zorro-antd-back-top.umd.min.js.map