1 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
2 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
3 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
4 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
5 | return c > 3 && r && Object.defineProperty(target, key, r), r;
|
6 | };
|
7 | var __metadata = (this && this.__metadata) || function (k, v) {
|
8 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
9 | };
|
10 | import { NgModule, Directive, ElementRef, HostBinding, Input } from '@angular/core';
|
11 | import { RippleRenderer, ForegroundRippleState } from './ripple-renderer';
|
12 | export var MdRipple = (function () {
|
13 | function MdRipple(_elementRef) {
|
14 | var _this = this;
|
15 | |
16 |
|
17 |
|
18 |
|
19 |
|
20 | this.maxRadius = 0;
|
21 | |
22 |
|
23 |
|
24 |
|
25 | this.speedFactor = 1;
|
26 |
|
27 | var eventHandlers = new Map();
|
28 | eventHandlers.set('mousedown', function (event) { return _this._mouseDown(event); });
|
29 | eventHandlers.set('click', function (event) { return _this._click(event); });
|
30 | eventHandlers.set('mouseleave', function (event) { return _this._mouseLeave(event); });
|
31 | this._rippleRenderer = new RippleRenderer(_elementRef, eventHandlers);
|
32 | }
|
33 |
|
34 | MdRipple.prototype.ngOnInit = function () {
|
35 |
|
36 | if (!this.trigger) {
|
37 | this._rippleRenderer.setTriggerElementToHost();
|
38 | }
|
39 | };
|
40 |
|
41 | MdRipple.prototype.ngOnDestroy = function () {
|
42 |
|
43 | this._rippleRenderer.clearTriggerElement();
|
44 | };
|
45 |
|
46 | MdRipple.prototype.ngOnChanges = function (changes) {
|
47 |
|
48 | var changedInputs = Object.keys(changes);
|
49 | if (changedInputs.indexOf('trigger') !== -1) {
|
50 | this._rippleRenderer.setTriggerElement(this.trigger);
|
51 | }
|
52 | };
|
53 | |
54 |
|
55 |
|
56 | MdRipple.prototype.start = function () {
|
57 | this._rippleRenderer.fadeInRippleBackground(this.backgroundColor);
|
58 | };
|
59 | |
60 |
|
61 |
|
62 |
|
63 |
|
64 | MdRipple.prototype.end = function (left, top, forceCenter) {
|
65 | var _this = this;
|
66 | if (forceCenter === void 0) { forceCenter = true; }
|
67 | this._rippleRenderer.createForegroundRipple(left, top, this.color, this.centered || forceCenter, this.maxRadius, this.speedFactor, function (ripple, e) { return _this._rippleTransitionEnded(ripple, e); });
|
68 | this._rippleRenderer.fadeOutRippleBackground();
|
69 | };
|
70 | MdRipple.prototype._rippleTransitionEnded = function (ripple, event) {
|
71 | if (event.propertyName === 'opacity') {
|
72 |
|
73 |
|
74 | switch (ripple.state) {
|
75 | case ForegroundRippleState.EXPANDING:
|
76 | this._rippleRenderer.fadeOutForegroundRipple(ripple.rippleElement);
|
77 | ripple.state = ForegroundRippleState.FADING_OUT;
|
78 | break;
|
79 | case ForegroundRippleState.FADING_OUT:
|
80 | this._rippleRenderer.removeRippleFromDom(ripple.rippleElement);
|
81 | break;
|
82 | }
|
83 | }
|
84 | };
|
85 | |
86 |
|
87 |
|
88 |
|
89 | MdRipple.prototype._mouseDown = function (event) {
|
90 | if (!this.disabled && event.button === 0) {
|
91 | this.start();
|
92 | }
|
93 | };
|
94 | |
95 |
|
96 |
|
97 |
|
98 | MdRipple.prototype._click = function (event) {
|
99 | if (!this.disabled && event.button === 0) {
|
100 |
|
101 |
|
102 |
|
103 | var isKeyEvent = (event.screenX === 0 && event.screenY === 0 && event.pageX === 0 && event.pageY === 0);
|
104 | this.end(event.pageX, event.pageY, isKeyEvent);
|
105 | }
|
106 | };
|
107 | |
108 |
|
109 |
|
110 | MdRipple.prototype._mouseLeave = function (event) {
|
111 |
|
112 | this._rippleRenderer.fadeOutRippleBackground();
|
113 | };
|
114 | __decorate([
|
115 | Input('md-ripple-trigger'),
|
116 | __metadata('design:type', Object)
|
117 | ], MdRipple.prototype, "trigger", void 0);
|
118 | __decorate([
|
119 | Input('md-ripple-centered'),
|
120 | __metadata('design:type', Boolean)
|
121 | ], MdRipple.prototype, "centered", void 0);
|
122 | __decorate([
|
123 | Input('md-ripple-disabled'),
|
124 | __metadata('design:type', Boolean)
|
125 | ], MdRipple.prototype, "disabled", void 0);
|
126 | __decorate([
|
127 | Input('md-ripple-max-radius'),
|
128 | __metadata('design:type', Number)
|
129 | ], MdRipple.prototype, "maxRadius", void 0);
|
130 | __decorate([
|
131 | Input('md-ripple-speed-factor'),
|
132 | __metadata('design:type', Number)
|
133 | ], MdRipple.prototype, "speedFactor", void 0);
|
134 | __decorate([
|
135 | Input('md-ripple-color'),
|
136 | __metadata('design:type', String)
|
137 | ], MdRipple.prototype, "color", void 0);
|
138 | __decorate([
|
139 | Input('md-ripple-background-color'),
|
140 | __metadata('design:type', String)
|
141 | ], MdRipple.prototype, "backgroundColor", void 0);
|
142 | __decorate([
|
143 | HostBinding('class.md-ripple-focused'),
|
144 | Input('md-ripple-focused'),
|
145 | __metadata('design:type', Boolean)
|
146 | ], MdRipple.prototype, "focused", void 0);
|
147 | __decorate([
|
148 | HostBinding('class.md-ripple-unbounded'),
|
149 | Input('md-ripple-unbounded'),
|
150 | __metadata('design:type', Boolean)
|
151 | ], MdRipple.prototype, "unbounded", void 0);
|
152 | MdRipple = __decorate([
|
153 | Directive({
|
154 | selector: '[md-ripple]',
|
155 | }),
|
156 | __metadata('design:paramtypes', [ElementRef])
|
157 | ], MdRipple);
|
158 | return MdRipple;
|
159 | }());
|
160 | export var MdRippleModule = (function () {
|
161 | function MdRippleModule() {
|
162 | }
|
163 | MdRippleModule.forRoot = function () {
|
164 | return {
|
165 | ngModule: MdRippleModule,
|
166 | providers: []
|
167 | };
|
168 | };
|
169 | MdRippleModule = __decorate([
|
170 | NgModule({
|
171 | exports: [MdRipple],
|
172 | declarations: [MdRipple],
|
173 | }),
|
174 | __metadata('design:paramtypes', [])
|
175 | ], MdRippleModule);
|
176 | return MdRippleModule;
|
177 | }());
|
178 |
|
179 |
|