@@ -40,8 +40,8 @@ export class RippleRenderer {
40
40
/** Element which triggers the ripple elements on mouse events. */
41
41
private _triggerElement : HTMLElement | null ;
42
42
43
- /** Whether the pointer is currently being held on the trigger or not. */
44
- private _isPointerDown : boolean = false ;
43
+ /** Whether the mouse is currently down or not. */
44
+ private _isMousedown : boolean = false ;
45
45
46
46
/** Events to be registered on the trigger element. */
47
47
private _triggerEvents = new Map < string , any > ( ) ;
@@ -62,12 +62,8 @@ export class RippleRenderer {
62
62
63
63
// Specify events which need to be registered on the trigger.
64
64
this . _triggerEvents . set ( 'mousedown' , this . onMousedown . bind ( this ) ) ;
65
- this . _triggerEvents . set ( 'touchstart' , this . onTouchstart . bind ( this ) ) ;
66
-
67
- this . _triggerEvents . set ( 'mouseup' , this . onPointerUp . bind ( this ) ) ;
68
- this . _triggerEvents . set ( 'touchend' , this . onPointerUp . bind ( this ) ) ;
69
-
70
- this . _triggerEvents . set ( 'mouseleave' , this . onPointerLeave . bind ( this ) ) ;
65
+ this . _triggerEvents . set ( 'mouseup' , this . onMouseup . bind ( this ) ) ;
66
+ this . _triggerEvents . set ( 'mouseleave' , this . onMouseup . bind ( this ) ) ;
71
67
72
68
// By default use the host element as trigger element.
73
69
this . setTriggerElement ( this . _containerElement ) ;
@@ -77,7 +73,7 @@ export class RippleRenderer {
77
73
/**
78
74
* Fades in a ripple at the given coordinates.
79
75
* @param x Coordinate within the element, along the X axis at which to start the ripple.
80
- * @param Y Coordinate within the element, along the Y axis at which to start the ripple.
76
+ * @param y Coordinate within the element, along the Y axis at which to start the ripple.
81
77
* @param config Extra ripple options.
82
78
*/
83
79
fadeInRipple ( x : number , y : number , config : RippleConfig = { } ) : RippleRef {
@@ -126,7 +122,7 @@ export class RippleRenderer {
126
122
this . runTimeoutOutsideZone ( ( ) => {
127
123
rippleRef . state = RippleState . VISIBLE ;
128
124
129
- if ( ! config . persistent && ! this . _isPointerDown ) {
125
+ if ( ! config . persistent && ! this . _isMousedown ) {
130
126
rippleRef . fadeOut ( ) ;
131
127
}
132
128
} , duration ) ;
@@ -182,14 +178,18 @@ export class RippleRenderer {
182
178
/** Function being called whenever the trigger is being pressed. */
183
179
private onMousedown ( event : MouseEvent ) {
184
180
if ( ! this . rippleDisabled ) {
185
- this . _isPointerDown = true ;
181
+ this . _isMousedown = true ;
186
182
this . fadeInRipple ( event . clientX , event . clientY , this . rippleConfig ) ;
187
183
}
188
184
}
189
185
190
- /** Function being called whenever the pointer is being released. */
191
- private onPointerUp ( ) {
192
- this . _isPointerDown = false ;
186
+ /** Function being called whenever the trigger is being released. */
187
+ private onMouseup ( ) {
188
+ if ( ! this . _isMousedown ) {
189
+ return ;
190
+ }
191
+
192
+ this . _isMousedown = false ;
193
193
194
194
// Fade-out all ripples that are completely visible and not persistent.
195
195
this . _activeRipples . forEach ( ripple => {
@@ -199,22 +199,6 @@ export class RippleRenderer {
199
199
} ) ;
200
200
}
201
201
202
- /** Function being called whenever the pointer leaves the trigger. */
203
- private onPointerLeave ( ) {
204
- if ( this . _isPointerDown ) {
205
- this . onPointerUp ( ) ;
206
- }
207
- }
208
-
209
- /** Function being called whenever the trigger is being touched. */
210
- private onTouchstart ( event : TouchEvent ) {
211
- if ( ! this . rippleDisabled ) {
212
- const { clientX, clientY} = event . touches [ 0 ] ;
213
- this . _isPointerDown = true ;
214
- this . fadeInRipple ( clientX , clientY , this . rippleConfig ) ;
215
- }
216
- }
217
-
218
202
/** Runs a timeout outside of the Angular zone to avoid triggering the change detection. */
219
203
private runTimeoutOutsideZone ( fn : Function , delay = 0 ) {
220
204
this . _ngZone . runOutsideAngular ( ( ) => setTimeout ( fn , delay ) ) ;
0 commit comments