UNPKG

ng-zorro-antd

Version:

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

2 lines 5.63 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/cdk/platform"),require("@angular/core"),require("@angular/platform-browser/animations")):"function"==typeof define&&define.amd?define("ng-zorro-antd/core/wave",["exports","@angular/cdk/platform","@angular/core","@angular/platform-browser/animations"],t):t(((e=e||self)["ng-zorro-antd"]=e["ng-zorro-antd"]||{},e["ng-zorro-antd"].core=e["ng-zorro-antd"].core||{},e["ng-zorro-antd"].core.wave={}),e.ng.cdk.platform,e.ng.core,e.ng.platformBrowser.animations)}(this,(function(e,t,r,n){"use strict";var o=function(){function e(e,r,n){var o=this;this.triggerElement=e,this.ngZone=r,this.insertExtraNode=n,this.waveTransitionDuration=400,this.lastTime=0,this.platform=new t.Platform,this.onClick=function(e){!o.triggerElement||!o.triggerElement.getAttribute||o.triggerElement.getAttribute("disabled")||"INPUT"===e.target.tagName||o.triggerElement.className.indexOf("disabled")>=0||o.fadeOutWave()},this.clickHandler=this.onClick.bind(this),this.bindTriggerEvent()}return Object.defineProperty(e.prototype,"waveAttributeName",{get:function(){return this.insertExtraNode?"ant-click-animating":"ant-click-animating-without-extra-node"},enumerable:!0,configurable:!0}),e.prototype.bindTriggerEvent=function(){var e=this;this.platform.isBrowser&&this.ngZone.runOutsideAngular((function(){e.removeTriggerEvent(),e.triggerElement&&e.triggerElement.addEventListener("click",e.clickHandler,!0)}))},e.prototype.removeTriggerEvent=function(){this.triggerElement&&this.triggerElement.removeEventListener("click",this.clickHandler,!0)},e.prototype.removeStyleAndExtraNode=function(){this.styleForPseudo&&document.body.contains(this.styleForPseudo)&&(document.body.removeChild(this.styleForPseudo),this.styleForPseudo=null),this.insertExtraNode&&this.triggerElement.contains(this.extraNode)&&this.triggerElement.removeChild(this.extraNode)},e.prototype.destroy=function(){this.removeTriggerEvent(),this.removeStyleAndExtraNode()},e.prototype.fadeOutWave=function(){var e=this,t=this.triggerElement,r=this.getWaveColor(t);t.setAttribute(this.waveAttributeName,"true"),Date.now()<this.lastTime+this.waveTransitionDuration||(this.isValidColor(r)&&(this.styleForPseudo||(this.styleForPseudo=document.createElement("style")),this.styleForPseudo.innerHTML="\n [ant-click-animating-without-extra-node='true']::after, .ant-click-animating-node {\n --antd-wave-shadow-color: "+r+";\n }",document.body.appendChild(this.styleForPseudo)),this.insertExtraNode&&(this.extraNode||(this.extraNode=document.createElement("div")),this.extraNode.className="ant-click-animating-node",t.appendChild(this.extraNode)),this.lastTime=Date.now(),this.runTimeoutOutsideZone((function(){t.removeAttribute(e.waveAttributeName),e.removeStyleAndExtraNode()}),this.waveTransitionDuration))},e.prototype.isValidColor=function(e){return!!e&&"#ffffff"!==e&&"rgb(255, 255, 255)"!==e&&this.isNotGrey(e)&&!/rgba\(\d*, \d*, \d*, 0\)/.test(e)&&"transparent"!==e},e.prototype.isNotGrey=function(e){var t=e.match(/rgba?\((\d*), (\d*), (\d*)(, [\.\d]*)?\)/);return!(t&&t[1]&&t[2]&&t[3])||!(t[1]===t[2]&&t[2]===t[3])},e.prototype.getWaveColor=function(e){var t=getComputedStyle(e);return t.getPropertyValue("border-top-color")||t.getPropertyValue("border-color")||t.getPropertyValue("background-color")},e.prototype.runTimeoutOutsideZone=function(e,t){this.ngZone.runOutsideAngular((function(){return setTimeout(e,t)}))},e}();var i={disabled:!1},a=new r.InjectionToken("nz-wave-global-options",{providedIn:"root",factory:s});function s(){return i}var d=function(){function e(e,t,r,n){this.ngZone=e,this.elementRef=t,this.config=r,this.animationType=n,this.nzWaveExtraNode=!1,this.waveDisabled=!1,this.waveDisabled=this.isConfigDisabled()}return Object.defineProperty(e.prototype,"disabled",{get:function(){return this.waveDisabled},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rendererRef",{get:function(){return this.waveRenderer},enumerable:!0,configurable:!0}),e.prototype.isConfigDisabled=function(){var e=!1;return this.config&&"boolean"==typeof this.config.disabled&&(e=this.config.disabled),"NoopAnimations"===this.animationType&&(e=!0),e},e.prototype.ngOnDestroy=function(){this.waveRenderer&&this.waveRenderer.destroy()},e.prototype.ngOnInit=function(){this.renderWaveIfEnabled()},e.prototype.renderWaveIfEnabled=function(){!this.waveDisabled&&this.elementRef.nativeElement&&(this.waveRenderer=new o(this.elementRef.nativeElement,this.ngZone,this.nzWaveExtraNode))},e.prototype.disable=function(){this.waveDisabled=!0,this.waveRenderer&&(this.waveRenderer.removeTriggerEvent(),this.waveRenderer.removeStyleAndExtraNode())},e.prototype.enable=function(){this.waveDisabled=this.isConfigDisabled()||!1,this.waveRenderer&&this.waveRenderer.bindTriggerEvent()},e.decorators=[{type:r.Directive,args:[{selector:"[nz-wave],button[nz-button]",exportAs:"nzWave"}]}],e.ctorParameters=function(){return[{type:r.NgZone},{type:r.ElementRef},{type:void 0,decorators:[{type:r.Optional},{type:r.Inject,args:[a]}]},{type:String,decorators:[{type:r.Optional},{type:r.Inject,args:[n.ANIMATION_MODULE_TYPE]}]}]},e.propDecorators={nzWaveExtraNode:[{type:r.Input}]},e}();var l=function(){function e(){}return e.decorators=[{type:r.NgModule,args:[{imports:[t.PlatformModule],exports:[d],declarations:[d]}]}],e}();e.NZ_WAVE_GLOBAL_CONFIG=a,e.NZ_WAVE_GLOBAL_CONFIG_FACTORY=s,e.NZ_WAVE_GLOBAL_DEFAULT_CONFIG=i,e.NzWaveDirective=d,e.NzWaveModule=l,e.NzWaveRenderer=o,Object.defineProperty(e,"__esModule",{value:!0})})); //# sourceMappingURL=ng-zorro-antd-core-wave.umd.min.js.map