@@ -140,6 +140,8 @@ InkRippleCtrl.prototype.bindEvents = function () {
140
140
* @param event {MouseEvent}
141
141
*/
142
142
InkRippleCtrl . prototype . handleMousedown = function ( event ) {
143
+ if ( this . mousedown ) return ;
144
+
143
145
// When jQuery is loaded, we have to get the original event
144
146
if ( event . hasOwnProperty ( 'originalEvent' ) ) event = event . originalEvent ;
145
147
this . mousedown = true ;
@@ -156,17 +158,23 @@ InkRippleCtrl.prototype.handleMousedown = function (event) {
156
158
* mouseup or mouseleave event)
157
159
*/
158
160
InkRippleCtrl . prototype . handleMouseup = function ( ) {
159
- var ctrl = this ;
160
- this . mousedown = false ;
161
- this . $mdUtil . nextTick ( function ( ) { ctrl . clearRipples ( ) ; } , false ) ;
161
+ if ( this . mousedown || this . lastRipple ) {
162
+ var ctrl = this ;
163
+ this . mousedown = false ;
164
+ this . $mdUtil . nextTick ( function ( ) {
165
+ ctrl . clearRipples ( ) ;
166
+ } , false ) ;
167
+ }
162
168
} ;
163
169
164
170
/**
165
171
* Cycles through all ripples and attempts to remove them.
166
172
* Depending on logic within `fadeInComplete`, some removals will be postponed.
167
173
*/
168
174
InkRippleCtrl . prototype . clearRipples = function ( ) {
169
- for ( var i = 0 ; i < this . ripples . length ; i ++ ) this . fadeInComplete ( this . ripples [ i ] ) ;
175
+ for ( var i = 0 ; i < this . ripples . length ; i ++ ) {
176
+ this . fadeInComplete ( this . ripples [ i ] ) ;
177
+ }
170
178
} ;
171
179
172
180
/**
@@ -222,9 +230,14 @@ InkRippleCtrl.prototype.createRipple = function (left, top) {
222
230
this . container . append ( ripple ) ;
223
231
this . ripples . push ( ripple ) ;
224
232
ripple . addClass ( 'md-ripple-placed' ) ;
233
+
225
234
this . $mdUtil . nextTick ( function ( ) {
235
+
226
236
ripple . addClass ( 'md-ripple-scaled md-ripple-active' ) ;
227
- ctrl . $timeout ( function ( ) { ctrl . clearRipples ( ) ; } , DURATION , false ) ;
237
+ ctrl . $timeout ( function ( ) {
238
+ ctrl . clearRipples ( ) ;
239
+ } , DURATION , false ) ;
240
+
228
241
} , false ) ;
229
242
230
243
function rgbaToRGB ( color ) {
@@ -246,7 +259,9 @@ InkRippleCtrl.prototype.createRipple = function (left, top) {
246
259
*/
247
260
InkRippleCtrl . prototype . fadeInComplete = function ( ripple ) {
248
261
if ( this . lastRipple === ripple ) {
249
- if ( ! this . timeout && ! this . mousedown ) this . removeRipple ( ripple ) ;
262
+ if ( ! this . timeout && ! this . mousedown ) {
263
+ this . removeRipple ( ripple ) ;
264
+ }
250
265
} else {
251
266
this . removeRipple ( ripple ) ;
252
267
}
@@ -265,14 +280,19 @@ InkRippleCtrl.prototype.removeRipple = function (ripple) {
265
280
if ( this . ripples . length === 0 ) this . container . css ( { backgroundColor : '' } ) ;
266
281
// use a 2-second timeout in order to allow for the animation to finish
267
282
// we don't actually care how long the animation takes
268
- this . $timeout ( function ( ) { ctrl . fadeOutComplete ( ripple ) ; } , DURATION , false ) ;
283
+ this . $timeout ( function ( ) {
284
+ ctrl . fadeOutComplete ( ripple ) ;
285
+ } , DURATION , false ) ;
269
286
} ;
270
287
271
288
/**
272
289
* Removes the provided ripple from the DOM
273
290
* @param ripple
274
291
*/
275
- InkRippleCtrl . prototype . fadeOutComplete = function ( ripple ) { ripple . remove ( ) ; } ;
292
+ InkRippleCtrl . prototype . fadeOutComplete = function ( ripple ) {
293
+ ripple . remove ( ) ;
294
+ this . lastRipple = null ;
295
+ } ;
276
296
277
297
/**
278
298
* Used to create an empty directive. This is used to track flag-directives whose children may have
0 commit comments