UNPKG

@angular-mdc/web

Version:
8 lines 7.09 kB
/** * @license * Copyright (c) Dominic Carretto * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://github.com/trimox/angular-mdc-web/blob/master/LICENSE */ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@angular/cdk/coercion"),require("@angular/cdk/platform"),require("@angular-mdc/web/dom"),require("@material/ripple/util"),require("@material/ripple")):"function"==typeof define&&define.amd?define("@angular-mdc/web/ripple",["exports","@angular/core","@angular/cdk/coercion","@angular/cdk/platform","@angular-mdc/web/dom","@material/ripple/util","@material/ripple"],t):t(((e=e||self).ng=e.ng||{},e.ng.web=e.ng.web||{},e.ng.web.ripple={}),e.ng.core,e.ng.cdk.coercion,e.ng.cdk.platform,e.ng.web.dom,e.mdc.ripple.util,e.mdc.ripple)}(this,(function(e,t,n,r,o,i,a){"use strict";var s=function(){return(s=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},u=function(){function e(t,n){this.element=t,this.initialized=!1,this._foundation=n||new a.MDCRippleFoundation(e.createAdapter({_root:t.nativeElement}))}return e.createAdapter=function(e){return{addClass:function(t){return e._root.classList.add(t)},removeClass:function(t){return e._root.classList.remove(t)},browserSupportsCssVars:function(){return"undefined"!=typeof window&&i.supportsCssVariables(window)},isUnbounded:function(){return n.coerceBooleanProperty(e.unbounded)},isSurfaceActive:function(){return o.matches(e._root,":active")},isSurfaceDisabled:function(){return n.coerceBooleanProperty(e.disabled)},containsEventTarget:function(t){return e._root.contains(t)},registerDocumentInteractionHandler:function(e,t){return"object"==typeof document&&document?document.documentElement.addEventListener(e,t,r.supportsPassiveEventListeners()):{}},deregisterDocumentInteractionHandler:function(e,t){return"object"==typeof document&&document?document.documentElement.removeEventListener(e,t,r.supportsPassiveEventListeners()):{}},registerResizeHandler:function(e){return"undefined"!=typeof window?window.addEventListener("resize",e):{}},deregisterResizeHandler:function(e){return"undefined"!=typeof window?window.removeEventListener("resize",e):{}},updateCssVariable:function(t,n){return e._root.style.setProperty(t,n)},computeBoundingRect:function(){return"object"==typeof document&&document?e._root.getBoundingClientRect():{top:0,right:0,bottom:0,left:0,width:0,height:0}},getWindowPageOffset:function(){return"undefined"!=typeof window?{x:window.pageXOffset,y:window.pageYOffset}:{x:0,y:0}},registerInteractionHandler:function(t,n){return e._root.addEventListener(t,n,r.supportsPassiveEventListeners())},deregisterInteractionHandler:function(t,n){return e._root.removeEventListener(t,n,r.supportsPassiveEventListeners())}}},e.prototype.init=function(){this.initialized||(this._foundation.init(),this.initialized=!0)},e.prototype.destroy=function(){this.initialized&&(this.initialized=!1,this._foundation.destroy())},e.prototype.layout=function(){this._foundation.layout()},e.prototype.ngOnDestroy=function(){this.destroy()},e.prototype.activateRipple=function(e){var t=this;setTimeout((function(){return t._foundation.activate(e)}))},e.prototype.deactivateRipple=function(){var e=this;setTimeout((function(){return e._foundation.deactivate()}))},e.prototype.handleBlur=function(){this._foundation.handleBlur()},e.decorators=[{type:t.Injectable}],e.ctorParameters=function(){return[{type:t.ElementRef},{type:a.MDCRippleFoundation,decorators:[{type:t.Optional}]}]},e}(),c=function(){function e(e,t){this._ripple=e,this.elementRef=t,this._primary=!1,this._secondary=!1,this._disabled=!1,this._unbounded=!1,this._root=this.elementRef.nativeElement,this._ripple=this._createRipple()}return Object.defineProperty(e.prototype,"attachTo",{get:function(){return this._attachTo},set:function(e){var t,n;this._attachTo=e,null===(n=null===(t=this._attachTo)||void 0===t?void 0:t.classList)||void 0===n||n.add("mdc-ripple-surface")},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"primary",{get:function(){return this._primary},set:function(e){this._primary=n.coerceBooleanProperty(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"secondary",{get:function(){return this._secondary},set:function(e){this._secondary=n.coerceBooleanProperty(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"disabled",{get:function(){return this._disabled},set:function(e){this._disabled=n.coerceBooleanProperty(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"unbounded",{get:function(){return this._unbounded},set:function(e){this._unbounded=n.coerceBooleanProperty(e)},enumerable:!0,configurable:!0}),e.prototype.ngOnChanges=function(e){e.primary&&this.attachTo&&(this._primary?this.attachTo.classList.add("mdc-ripple-surface--primary"):this.attachTo.classList.remove("mdc-ripple-surface--primary")),e.secondary&&this.attachTo&&(this._secondary?this.attachTo.classList.add("mdc-ripple-surface--accent"):this.attachTo.classList.remove("mdc-ripple-surface--accent"))},e.prototype.ngAfterViewInit=function(){this._ripple.init()},e.prototype.ngOnDestroy=function(){this._ripple.destroy()},e.prototype._createRipple=function(){var e=this,t=s(s({},u.createAdapter(this)),{addClass:function(t){var n,r;return null===(r=null===(n=e.attachTo)||void 0===n?void 0:n.classList)||void 0===r?void 0:r.add(t)},computeBoundingRect:function(){var t,n;return null!=(n=null===(t=e.attachTo)||void 0===t?void 0:t.getBoundingClientRect())?n:{top:0,right:0,bottom:0,left:0,width:0,height:0}},isSurfaceActive:function(){return o.matches(e.attachTo,":active")},isSurfaceDisabled:function(){return e._disabled},isUnbounded:function(){return e._unbounded},removeClass:function(t){var n,r;return null===(r=null===(n=e.attachTo)||void 0===n?void 0:n.classList)||void 0===r?void 0:r.remove(t)},updateCssVariable:function(t,n){var r,o;return null===(o=null===(r=e.attachTo)||void 0===r?void 0:r.style)||void 0===o?void 0:o.setProperty(t,n)},registerInteractionHandler:function(t,n){var o;return null===(o=e.attachTo)||void 0===o?void 0:o.addEventListener(t,n,r.supportsPassiveEventListeners())},deregisterInteractionHandler:function(t,n){var o;return null===(o=e.attachTo)||void 0===o?void 0:o.removeEventListener(t,n,r.supportsPassiveEventListeners())}});return new u(this.elementRef,new a.MDCRippleFoundation(t))},e.decorators=[{type:t.Directive,args:[{selector:"[mdcRipple], mdc-ripple",providers:[u]}]}],e.ctorParameters=function(){return[{type:u},{type:t.ElementRef}]},e.propDecorators={attachTo:[{type:t.Input}],primary:[{type:t.Input}],secondary:[{type:t.Input}],disabled:[{type:t.Input}],unbounded:[{type:t.Input}]},e}(),d=function(){function e(){}return e.decorators=[{type:t.NgModule,args:[{exports:[c],declarations:[c]}]}],e}();e.MdcRipple=u,e.MdcRippleDirective=c,e.MdcRippleModule=d,Object.defineProperty(e,"__esModule",{value:!0})}));