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

Commit 65b2454

Browse files
EladBezalelThomasBurleson
authored andcommitted
fix(ripple): removing ripples on touchmove
When touching a button in order to scroll, the button creates a ripple as its being pressed, now when the touch moved we assume that this gesture is a scroll so we remove all the ripple effects fixes #5261. closes #5532.
1 parent f30dd8c commit 65b2454

File tree

1 file changed

+33
-5
lines changed

1 file changed

+33
-5
lines changed

src/core/services/ripple/ripple.js

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,8 @@ InkRippleCtrl.prototype._parseColor = function parseColor (color, multiplier) {
135135
*/
136136
InkRippleCtrl.prototype.bindEvents = function () {
137137
this.$element.on('mousedown', angular.bind(this, this.handleMousedown));
138-
this.$element.on('mouseup', angular.bind(this, this.handleMouseup));
139-
this.$element.on('mouseleave', angular.bind(this, this.handleMouseup));
138+
this.$element.on('mouseup touchend mouseleave', angular.bind(this, this.handleMouseup));
139+
this.$element.on('touchmove', angular.bind(this, this.handleTouchmove));
140140
};
141141

142142
/**
@@ -162,18 +162,46 @@ InkRippleCtrl.prototype.handleMousedown = function (event) {
162162
* Either remove or unlock any remaining ripples when the user mouses off of the element (either by
163163
* mouseup or mouseleave event)
164164
*/
165-
InkRippleCtrl.prototype.handleMouseup = function () {
165+
InkRippleCtrl.prototype._handleRemoval = function (cb) {
166166
if ( this.mousedown || this.lastRipple ) {
167-
var ctrl = this;
168167
this.mousedown = false;
169168
this.$mdUtil.nextTick(function () {
170-
ctrl.clearRipples();
169+
cb();
171170
}, false);
172171
}
173172
};
174173

174+
/**
175+
* Either remove or unlock any remaining ripples when the user mouses off of the element (either by
176+
* mouseup, touchend or mouseleave event)
177+
*/
178+
InkRippleCtrl.prototype.handleMouseup = function () {
179+
var ctrl = this;
180+
181+
ctrl._handleRemoval(angular.bind(ctrl, ctrl.clearRipples));
182+
};
183+
184+
/**
185+
* Either remove or unlock any remaining ripples when the user mouses off of the element (by
186+
* touchmove)
187+
*/
188+
InkRippleCtrl.prototype.handleTouchmove = function () {
189+
var ctrl = this;
190+
191+
ctrl._handleRemoval(angular.bind(ctrl, ctrl.deleteRipples));
192+
};
193+
175194
/**
176195
* Cycles through all ripples and attempts to remove them.
196+
*/
197+
InkRippleCtrl.prototype.deleteRipples = function () {
198+
for (var i = 0; i < this.ripples.length; i++) {
199+
this.ripples[ i ].remove();
200+
}
201+
};
202+
203+
/**
204+
* Cycles through all ripples and attempts to remove them with fade.
177205
* Depending on logic within `fadeInComplete`, some removals will be postponed.
178206
*/
179207
InkRippleCtrl.prototype.clearRipples = function () {

0 commit comments

Comments
 (0)