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

feat(ripple): ink-ripple is now getting an interpolated value #5580

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 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,8 +144,6 @@ InkRippleCtrl.prototype.bindEvents = function () {
InkRippleCtrl.prototype.handleMousedown = function (event) {
if ( this.mousedown ) return;

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

// When jQuery is loaded, we have to get the original event
if (event.hasOwnProperty('originalEvent')) event = event.originalEvent;
this.mousedown = true;
Expand Down Expand Up @@ -203,7 +199,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 All @@ -224,6 +225,8 @@ InkRippleCtrl.prototype.createRipple = function (left, top) {
var y = Math.max(Math.abs(height - top), top) * 2;
var size = getSize(this.options.fitRipple, x, y);

this.updateColor();

ripple.css({
left: left + 'px',
top: top + 'px',
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