UNPKG

ng-zorro-antd

Version:

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

16 lines (14 loc) 4.9 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/animation"),require("ng-zorro-antd/core/config"),require("ng-zorro-antd/core/services"),require("ng-zorro-antd/core/util"),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/animation","ng-zorro-antd/core/config","ng-zorro-antd/core/services","ng-zorro-antd/core/util","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.animation,t["ng-zorro-antd"].core.config,t["ng-zorro-antd"].core.services,t["ng-zorro-antd"].core.util,t.rxjs,t.rxjs.operators)}(this,(function(t,e,o,r,n,i,c,a,s,l){"use strict"; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR NON-INFRINGEMENT. See the Apache Version 2.0 License for specific language governing permissions and limitations under the License. ***************************************************************************** */function p(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}var g=function(){function t(t,e,o,n,i,c){this.doc=t,this.nzConfigService=e,this.scrollSrv=o,this.platform=n,this.cd=i,this.zone=c,this.scrollListenerDestroy$=new s.Subject,this.target=null,this.visible=!1,this.nzClick=new r.EventEmitter}return t.prototype.ngOnInit=function(){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.detectChanges())},t.prototype.registerScrollEvent=function(){var t=this;this.platform.isBrowser&&(this.scrollListenerDestroy$.next(),this.handleScroll(),this.zone.runOutsideAngular((function(){s.fromEvent(t.getTarget(),"scroll").pipe(l.throttleTime(50),l.takeUntil(t.scrollListenerDestroy$)).subscribe((function(){return t.handleScroll()}))})))},t.prototype.ngOnDestroy=function(){this.scrollListenerDestroy$.next(),this.scrollListenerDestroy$.complete()},t.prototype.ngOnChanges=function(t){t.nzTarget&&(this.target="string"==typeof this.nzTarget?this.doc.querySelector(this.nzTarget):this.nzTarget,this.registerScrollEvent())},t.decorators=[{type:r.Component,args:[{selector:"nz-back-top",exportAs:"nzBackTop",animations:[n.fadeMotion],template:'\n <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>\n ',changeDetection:r.ChangeDetectionStrategy.OnPush,encapsulation:r.ViewEncapsulation.None,preserveWhitespaces:!1}]}],t.ctorParameters=function(){return[{type:void 0,decorators:[{type:r.Inject,args:[o.DOCUMENT]}]},{type:i.NzConfigService},{type:c.NzScrollService},{type:e.Platform},{type:r.ChangeDetectorRef},{type:r.NgZone}]},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 a=t.length-1;a>=0;a--)(n=t[a])&&(c=(i<3?n(c):i>3?n(e,o,c):n(e,o))||c);i>3&&c&&Object.defineProperty(e,o,c)}([i.WithConfig("backTop",400),a.InputNumber(),p("design:type",Number)],t.prototype,"nzVisibilityHeight",void 0),t}();var u=function(){function t(){}return t.decorators=[{type:r.NgModule,args:[{declarations:[g],exports:[g],imports:[o.CommonModule,e.PlatformModule],providers:[c.SCROLL_SERVICE_PROVIDER]}]}],t}();t.NzBackTopComponent=g,t.NzBackTopModule=u,Object.defineProperty(t,"__esModule",{value:!0})})); //# sourceMappingURL=ng-zorro-antd-back-top.umd.min.js.map