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

fix(ripple): removing ripples on touchmove #5532

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
38 changes: 33 additions & 5 deletions src/core/services/ripple/ripple.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ InkRippleCtrl.prototype._parseColor = function parseColor (color, multiplier) {
*/
InkRippleCtrl.prototype.bindEvents = function () {
this.$element.on('mousedown', angular.bind(this, this.handleMousedown));
this.$element.on('mouseup', angular.bind(this, this.handleMouseup));
this.$element.on('mouseleave', angular.bind(this, this.handleMouseup));
this.$element.on('mouseup touchend mouseleave', angular.bind(this, this.handleMouseup));
this.$element.on('touchmove', angular.bind(this, this.handleTouchmove));
};

/**
Expand All @@ -162,18 +162,46 @@ InkRippleCtrl.prototype.handleMousedown = function (event) {
* Either remove or unlock any remaining ripples when the user mouses off of the element (either by
* mouseup or mouseleave event)
*/
InkRippleCtrl.prototype.handleMouseup = function () {
InkRippleCtrl.prototype._handleRemoval = function (cb) {
if ( this.mousedown || this.lastRipple ) {
var ctrl = this;
this.mousedown = false;
this.$mdUtil.nextTick(function () {
ctrl.clearRipples();
cb();
}, false);
}
};

/**
* Either remove or unlock any remaining ripples when the user mouses off of the element (either by
* mouseup, touchend or mouseleave event)
*/
InkRippleCtrl.prototype.handleMouseup = function () {
var ctrl = this;

ctrl._handleRemoval(angular.bind(ctrl, ctrl.clearRipples));
};

/**
* Either remove or unlock any remaining ripples when the user mouses off of the element (by
* touchmove)
*/
InkRippleCtrl.prototype.handleTouchmove = function () {
var ctrl = this;

ctrl._handleRemoval(angular.bind(ctrl, ctrl.deleteRipples));
};

/**
* Cycles through all ripples and attempts to remove them.
*/
InkRippleCtrl.prototype.deleteRipples = function () {
for (var i = 0; i < this.ripples.length; i++) {
this.ripples[ i ].remove();
}
};

/**
* Cycles through all ripples and attempts to remove them with fade.
* Depending on logic within `fadeInComplete`, some removals will be postponed.
*/
InkRippleCtrl.prototype.clearRipples = function () {
Expand Down