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AAC,KAAK,CAAC,wBAAwB,CAAC;;iDAAA;IAEhC;QAAC,KAAK,CAAC,iBAAiB,CAAC;;2CAAA;IAEzB;QAAC,KAAK,CAAC,4BAA4B,CAAC;;qDAAA;IAGpC;QAAC,WAAW,CAAC,yBAAyB,CAAC;QAAE,KAAK,CAAC,mBAAmB,CAAC;;6CAAA;IAEnE;QAAC,WAAW,CAAC,2BAA2B,CAAC;QAAE,KAAK,CAAC,qBAAqB,CAAC;;+CAAA;IAxCzE;QAAC,SAAS,CAAC;YACT,QAAQ,EAAE,aAAa;SACxB,CAAC;;gBAAA;IAoJF,eAAC;AAAD,CAnJA,AAmJC,IAAA;AAOD;IAAA;IAOA,CAAC;IANQ,sBAAO,GAAd;QACE,MAAM,CAAC;YACL,QAAQ,EAAE,cAAc;YACxB,SAAS,EAAE,EAAE;SACd,CAAC;IACJ,CAAC;IAVH;QAAC,QAAQ,CAAC;YACR,OAAO,EAAE,CAAC,QAAQ,CAAC;YACnB,YAAY,EAAE,CAAC,QAAQ,CAAC;SACzB,CAAC;;sBAAA;IAQF,qBAAC;AAAD,CAPA,AAOC,IAAA","file":"core/ripple/ripple.js","sourcesContent":["import {\n NgModule,\n ModuleWithProviders,\n Directive,\n ElementRef,\n HostBinding,\n Input,\n OnChanges,\n OnDestroy,\n OnInit,\n SimpleChange,\n} from '@angular/core';\nimport {\n RippleRenderer,\n ForegroundRipple,\n ForegroundRippleState,\n} from './ripple-renderer';\n\n\n@Directive({\n selector: '[md-ripple]',\n})\nexport class MdRipple implements OnInit, OnDestroy, OnChanges {\n /**\n * The element that triggers the ripple when click events are received. Defaults to the\n * directive's host element.\n */\n // Prevent TS metadata emit from referencing HTMLElement in ripple.js\n // That breaks tests running in node that load material components.\n @Input('md-ripple-trigger') trigger: HTMLElement|HTMLElement;\n /**\n * Whether the ripple always originates from the center of the host element's bounds, rather\n * than originating from the location of the click event.\n */\n @Input('md-ripple-centered') centered: boolean;\n /**\n * Whether click events will not trigger the ripple. It can still be triggered by manually\n * calling start() and end().\n */\n @Input('md-ripple-disabled') disabled: boolean;\n /**\n * If set, the radius in pixels of foreground ripples when fully expanded. If unset, the radius\n * will be the distance from the center of the ripple to the furthest corner of the host element's\n * bounding rectangle.\n */\n @Input('md-ripple-max-radius') maxRadius: number = 0;\n /**\n * If set, the normal duration of ripple animations is divided by this value. For example,\n * setting it to 0.5 will cause the animations to take twice as long.\n */\n @Input('md-ripple-speed-factor') speedFactor: number = 1;\n /** Custom color for ripples. */\n @Input('md-ripple-color') color: string;\n /** Custom color for the ripple background. */\n @Input('md-ripple-background-color') backgroundColor: string;\n\n /** Whether the ripple background will be highlighted to indicated a focused state. */\n @HostBinding('class.md-ripple-focused') @Input('md-ripple-focused') focused: boolean;\n /** Whether foreground ripples should be visible outside the component's bounds. */\n @HostBinding('class.md-ripple-unbounded') @Input('md-ripple-unbounded') unbounded: boolean;\n\n private _rippleRenderer: RippleRenderer;\n\n constructor(_elementRef: ElementRef) {\n // These event handlers are attached to the element that triggers the ripple animations.\n const eventHandlers = new Map<string, (e: Event) => void>();\n eventHandlers.set('mousedown', (event: MouseEvent) => this._mouseDown(event));\n eventHandlers.set('click', (event: MouseEvent) => this._click(event));\n eventHandlers.set('mouseleave', (event: MouseEvent) => this._mouseLeave(event));\n this._rippleRenderer = new RippleRenderer(_elementRef, eventHandlers);\n }\n\n /** TODO: internal */\n ngOnInit() {\n // If no trigger element was explicity set, use the host element\n if (!this.trigger) {\n this._rippleRenderer.setTriggerElementToHost();\n }\n }\n\n /** TODO: internal */\n ngOnDestroy() {\n // Remove event listeners on the trigger element.\n this._rippleRenderer.clearTriggerElement();\n }\n\n /** TODO: internal */\n ngOnChanges(changes: { [propertyName: string]: SimpleChange }) {\n // If the trigger element changed (or is being initially set), add event listeners to it.\n const changedInputs = Object.keys(changes);\n if (changedInputs.indexOf('trigger') !== -1) {\n this._rippleRenderer.setTriggerElement(this.trigger);\n }\n }\n\n /**\n * Responds to the start of a ripple animation trigger by fading the background in.\n */\n start() {\n this._rippleRenderer.fadeInRippleBackground(this.backgroundColor);\n }\n\n /**\n * Responds to the end of a ripple animation trigger by fading the background out, and creating a\n * foreground ripple that expands from the event location (or from the center of the element if\n * the \"centered\" property is set or forceCenter is true).\n */\n end(left: number, top: number, forceCenter = true) {\n this._rippleRenderer.createForegroundRipple(\n left,\n top,\n this.color,\n this.centered || forceCenter,\n this.maxRadius,\n this.speedFactor,\n (ripple: ForegroundRipple, e: TransitionEvent) => this._rippleTransitionEnded(ripple, e));\n this._rippleRenderer.fadeOutRippleBackground();\n }\n\n private _rippleTransitionEnded(ripple: ForegroundRipple, event: TransitionEvent) {\n if (event.propertyName === 'opacity') {\n // If the ripple finished expanding, start fading it out. If it finished fading out,\n // remove it from the DOM.\n switch (ripple.state) {\n case ForegroundRippleState.EXPANDING:\n this._rippleRenderer.fadeOutForegroundRipple(ripple.rippleElement);\n ripple.state = ForegroundRippleState.FADING_OUT;\n break;\n case ForegroundRippleState.FADING_OUT:\n this._rippleRenderer.removeRippleFromDom(ripple.rippleElement);\n break;\n }\n }\n }\n\n /**\n * Called when the trigger element receives a mousedown event. Starts the ripple animation by\n * fading in the background.\n */\n private _mouseDown(event: MouseEvent) {\n if (!this.disabled && event.button === 0) {\n this.start();\n }\n }\n\n /**\n * Called when the trigger element receives a click event. Creates a foreground ripple and\n * runs its animation.\n */\n private _click(event: MouseEvent) {\n if (!this.disabled && event.button === 0) {\n // If screen and page positions are all 0, this was probably triggered by a keypress.\n // In that case, use the center of the bounding rect as the ripple origin.\n // FIXME: This fails on IE11, which still sets pageX/Y and screenX/Y on keyboard clicks.\n const isKeyEvent =\n (event.screenX === 0 && event.screenY === 0 && event.pageX === 0 && event.pageY === 0);\n this.end(event.pageX, event.pageY, isKeyEvent);\n }\n }\n\n /**\n * Called when the trigger element receives a mouseleave event. Fades out the background.\n */\n private _mouseLeave(event: MouseEvent) {\n // We can always fade out the background here; It's a no-op if it was already inactive.\n this._rippleRenderer.fadeOutRippleBackground();\n }\n\n // TODO: Reactivate the background div if the user drags out and back in.\n}\n\n\n@NgModule({\n exports: [MdRipple],\n declarations: [MdRipple],\n})\nexport class MdRippleModule {\n static forRoot(): ModuleWithProviders {\n return {\n ngModule: MdRippleModule,\n providers: []\n };\n }\n}\n"],"sourceRoot":"/source/"}
\No newline at end of file