@@ -31,16 +31,16 @@ export type RippleConfig = {
31
31
export class RippleRenderer {
32
32
33
33
/** Element where the ripples are being added to. */
34
- private _targetElement : HTMLElement ;
34
+ private _containerElement : HTMLElement ;
35
35
36
36
/** Element which triggers the ripple elements on mouse events. */
37
37
private _triggerElement : HTMLElement ;
38
38
39
39
/** Whether the mouse is currently down or not. */
40
40
private _isMousedown : boolean = false ;
41
41
42
- /** Currently showing ripples that will be closed on mouseup. */
43
- private _showingRipples : HTMLElement [ ] = [ ] ;
42
+ /** Currently active ripples that will be closed on mouseup. */
43
+ private _activeRipples : HTMLElement [ ] = [ ] ;
44
44
45
45
/** Events to be registered on the trigger element. */
46
46
private _triggerEvents = new Map < string , any > ( ) ;
@@ -52,24 +52,24 @@ export class RippleRenderer {
52
52
rippleDisabled : boolean = false ;
53
53
54
54
constructor ( _elementRef : ElementRef , private _ngZone : NgZone , private _ruler : ViewportRuler ) {
55
- this . _targetElement = _elementRef . nativeElement ;
55
+ this . _containerElement = _elementRef . nativeElement ;
56
56
57
57
// Specify events which need to be registered on the trigger.
58
58
this . _triggerEvents . set ( 'mousedown' , this . onMousedown . bind ( this ) ) ;
59
59
this . _triggerEvents . set ( 'mouseup' , this . onMouseup . bind ( this ) ) ;
60
60
this . _triggerEvents . set ( 'mouseleave' , this . onMouseLeave . bind ( this ) ) ;
61
61
62
62
// By default use the host element as trigger element.
63
- this . setTriggerElement ( this . _targetElement ) ;
63
+ this . setTriggerElement ( this . _containerElement ) ;
64
64
}
65
65
66
66
/** Fades in a ripple at the given coordinates. */
67
67
fadeInRipple ( pageX : number , pageY : number , config : RippleConfig = { } ) {
68
- let targetRect = this . _targetElement . getBoundingClientRect ( ) ;
68
+ let containerRect = this . _containerElement . getBoundingClientRect ( ) ;
69
69
70
70
if ( config . centered ) {
71
- pageX = targetRect . left + targetRect . width / 2 ;
72
- pageY = targetRect . top + targetRect . height / 2 ;
71
+ pageX = containerRect . left + containerRect . width / 2 ;
72
+ pageY = containerRect . top + containerRect . height / 2 ;
73
73
} else {
74
74
// Subtract scroll values from the coordinates because calculations below
75
75
// are always relative to the viewport rectangle.
@@ -78,10 +78,10 @@ export class RippleRenderer {
78
78
pageY -= scrollPosition . top ;
79
79
}
80
80
81
- let radius = config . radius || distanceToFurthestCorner ( pageX , pageY , targetRect ) ;
81
+ let radius = config . radius || distanceToFurthestCorner ( pageX , pageY , containerRect ) ;
82
82
let duration = 1 / ( config . speedFactor || 1 ) * ( radius / RIPPLE_SPEED_PX_PER_SECOND ) ;
83
- let offsetX = pageX - targetRect . left ;
84
- let offsetY = pageY - targetRect . top ;
83
+ let offsetX = pageX - containerRect . left ;
84
+ let offsetY = pageY - containerRect . top ;
85
85
86
86
let ripple = document . createElement ( 'div' ) ;
87
87
ripple . classList . add ( 'md-ripple-element' ) ;
@@ -95,7 +95,7 @@ export class RippleRenderer {
95
95
ripple . style . backgroundColor = config . color ;
96
96
ripple . style . transitionDuration = `${ duration } s` ;
97
97
98
- this . _targetElement . appendChild ( ripple ) ;
98
+ this . _containerElement . appendChild ( ripple ) ;
99
99
100
100
// By default the browser does not recalculate the styles of dynamically created
101
101
// ripple elements. This is critical because then the `scale` would not animate properly.
@@ -108,7 +108,7 @@ export class RippleRenderer {
108
108
// Wait for the ripple to be faded in. Once faded in the ripple can be hided if the mouse is
109
109
// released.
110
110
this . runTimeoutOutsideZone ( ( ) => {
111
- this . _isMousedown ? this . _showingRipples . push ( ripple ) : this . fadeOutRipple ( ripple ) ;
111
+ this . _isMousedown ? this . _activeRipples . push ( ripple ) : this . fadeOutRipple ( ripple ) ;
112
112
} , duration * 1000 ) ;
113
113
}
114
114
@@ -151,8 +151,8 @@ export class RippleRenderer {
151
151
/** Listener being called on mouseup event. */
152
152
private onMouseup ( ) {
153
153
this . _isMousedown = false ;
154
- this . _showingRipples . forEach ( ripple => this . fadeOutRipple ( ripple ) ) ;
155
- this . _showingRipples = [ ] ;
154
+ this . _activeRipples . forEach ( ripple => this . fadeOutRipple ( ripple ) ) ;
155
+ this . _activeRipples = [ ] ;
156
156
}
157
157
158
158
/** Listener being called on mouseleave event. */
0 commit comments