Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

Commit be4311a

Browse files
author
Robert Messerle
committed
fix(ripple): fixes js error on button click for date picker
1 parent dbca2a4 commit be4311a

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/core/services/ripple/ripple.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,29 @@ function InkRippleCtrl ($scope, $element, rippleOptions, $window, $timeout, $mdU
5151
this.options = rippleOptions;
5252
this.mousedown = false;
5353
this.ripples = [];
54-
this.container = null;
55-
this.color = null;
56-
this.background = null;
5754
this.timeout = null; // Stores a reference to the most-recent ripple timeout
5855
this.lastRipple = null;
5956

57+
this.valueOnUse('container', angular.bind(this, this.createContainer));
58+
this.valueOnUse('color', angular.bind(this, this.getColor, 1));
59+
this.valueOnUse('background', angular.bind(this, this.getColor, 0.5));
60+
6061
// attach method for unit tests
6162
($element.controller('mdInkRipple') || {}).createRipple = angular.bind(this, this.createRipple);
6263

6364
this.bindEvents();
6465
}
6566

67+
InkRippleCtrl.prototype.valueOnUse = function (key, getter) {
68+
var value = null;
69+
Object.defineProperty(this, key, {
70+
get: function () {
71+
if (value === null) value = getter();
72+
return value;
73+
}
74+
});
75+
};
76+
6677
/**
6778
* Returns the color that the ripple should be (either based on CSS or hard-coded)
6879
* @returns {string}
@@ -189,10 +200,6 @@ InkRippleCtrl.prototype.clearTimeout = function () {
189200
* @param top
190201
*/
191202
InkRippleCtrl.prototype.createRipple = function (left, top) {
192-
if (!this.container) this.container = this.createContainer();
193-
if (!this.color) this.color = this.getColor();
194-
if (!this.background) this.background = this.getColor(0.5);
195-
196203
var ctrl = this;
197204
var ripple = angular.element('<div class="md-ripple"></div>');
198205
var width = this.$element.prop('clientWidth');

0 commit comments

Comments
 (0)