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

Commit

Permalink
feat(ripple): ink-ripple is now getting an interpolated value
Browse files Browse the repository at this point in the history
Ink ripple attribute supported only colors.
Now with interpolated value also boolean values are supported

<div md-ink-ripple="{{myFunc()}}">yay</div>

fixes #5438
  • Loading branch information
EladBezalel committed Nov 5, 2015
1 parent 27c65fd commit 39c3565
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/core/services/ripple/ripple.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ function InkRippleCtrl ($scope, $element, rippleOptions, $window, $timeout, $mdU
this.lastRipple = null;

$mdUtil.valueOnUse(this, 'container', this.createContainer);
$mdUtil.valueOnUse(this, 'background', this.getColor, 0.5);

this.color = this.getColor(1);
this.$element.addClass('md-ink-ripple');

// attach method for unit tests
Expand Down Expand Up @@ -146,7 +144,7 @@ InkRippleCtrl.prototype.bindEvents = function () {
InkRippleCtrl.prototype.handleMousedown = function (event) {
if ( this.mousedown ) return;

this.setColor(window.getComputedStyle(this.$element[0])['color']);
this.updateColor();

// When jQuery is loaded, we have to get the original event
if (event.hasOwnProperty('originalEvent')) event = event.originalEvent;
Expand Down Expand Up @@ -203,7 +201,12 @@ InkRippleCtrl.prototype.isRippleAllowed = function () {
var element = this.$element[0];
do {
if (!element.tagName || element.tagName === 'BODY') break;
if (element && element.hasAttribute && element.hasAttribute('disabled')) return false;
if (element && element.hasAttribute) {
var rippleValue = element.hasAttribute('md-ink-ripple') ? element.attributes['md-ink-ripple'].value : '';

if (element.hasAttribute('disabled')) return false;
if (rippleValue === 'false' || rippleValue === '0') return false;
}
} while (element = element.parentNode);
return true;
};
Expand Down Expand Up @@ -269,8 +272,20 @@ InkRippleCtrl.prototype.createRipple = function (left, top) {
}
};

/**
* Gets a color and apply it to background and the ripple color
* @param color
*/
InkRippleCtrl.prototype.setColor = function (color) {
this.color = this._parseColor(color);
this.background = this.color;
};

/**
* Updating the ripple colors
*/
InkRippleCtrl.prototype.updateColor = function () {
this.setColor(this.getColor());
};

/**
Expand Down

0 comments on commit 39c3565

Please sign in to comment.