@@ -31,16 +31,16 @@ export type RippleConfig = {
3131export class RippleRenderer {
3232
3333 /** Element where the ripples are being added to. */
34- private _targetElement : HTMLElement ;
34+ private _containerElement : HTMLElement ;
3535
3636 /** Element which triggers the ripple elements on mouse events. */
3737 private _triggerElement : HTMLElement ;
3838
3939 /** Whether the mouse is currently down or not. */
4040 private _isMousedown : boolean = false ;
4141
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 [ ] = [ ] ;
4444
4545 /** Events to be registered on the trigger element. */
4646 private _triggerEvents = new Map < string , any > ( ) ;
@@ -52,24 +52,24 @@ export class RippleRenderer {
5252 rippleDisabled : boolean = false ;
5353
5454 constructor ( _elementRef : ElementRef , private _ngZone : NgZone , private _ruler : ViewportRuler ) {
55- this . _targetElement = _elementRef . nativeElement ;
55+ this . _containerElement = _elementRef . nativeElement ;
5656
5757 // Specify events which need to be registered on the trigger.
5858 this . _triggerEvents . set ( 'mousedown' , this . onMousedown . bind ( this ) ) ;
5959 this . _triggerEvents . set ( 'mouseup' , this . onMouseup . bind ( this ) ) ;
6060 this . _triggerEvents . set ( 'mouseleave' , this . onMouseLeave . bind ( this ) ) ;
6161
6262 // By default use the host element as trigger element.
63- this . setTriggerElement ( this . _targetElement ) ;
63+ this . setTriggerElement ( this . _containerElement ) ;
6464 }
6565
6666 /** Fades in a ripple at the given coordinates. */
6767 fadeInRipple ( pageX : number , pageY : number , config : RippleConfig = { } ) {
68- let targetRect = this . _targetElement . getBoundingClientRect ( ) ;
68+ let containerRect = this . _containerElement . getBoundingClientRect ( ) ;
6969
7070 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 ;
7373 } else {
7474 // Subtract scroll values from the coordinates because calculations below
7575 // are always relative to the viewport rectangle.
@@ -78,10 +78,10 @@ export class RippleRenderer {
7878 pageY -= scrollPosition . top ;
7979 }
8080
81- let radius = config . radius || distanceToFurthestCorner ( pageX , pageY , targetRect ) ;
81+ let radius = config . radius || distanceToFurthestCorner ( pageX , pageY , containerRect ) ;
8282 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 ;
8585
8686 let ripple = document . createElement ( 'div' ) ;
8787 ripple . classList . add ( 'md-ripple-element' ) ;
@@ -95,7 +95,7 @@ export class RippleRenderer {
9595 ripple . style . backgroundColor = config . color ;
9696 ripple . style . transitionDuration = `${ duration } s` ;
9797
98- this . _targetElement . appendChild ( ripple ) ;
98+ this . _containerElement . appendChild ( ripple ) ;
9999
100100 // By default the browser does not recalculate the styles of dynamically created
101101 // ripple elements. This is critical because then the `scale` would not animate properly.
@@ -108,7 +108,7 @@ export class RippleRenderer {
108108 // Wait for the ripple to be faded in. Once faded in the ripple can be hided if the mouse is
109109 // released.
110110 this . runTimeoutOutsideZone ( ( ) => {
111- this . _isMousedown ? this . _showingRipples . push ( ripple ) : this . fadeOutRipple ( ripple ) ;
111+ this . _isMousedown ? this . _activeRipples . push ( ripple ) : this . fadeOutRipple ( ripple ) ;
112112 } , duration * 1000 ) ;
113113 }
114114
@@ -151,8 +151,8 @@ export class RippleRenderer {
151151 /** Listener being called on mouseup event. */
152152 private onMouseup ( ) {
153153 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 = [ ] ;
156156 }
157157
158158 /** Listener being called on mouseleave event. */
0 commit comments