@@ -6,25 +6,25 @@ import {
66} from '@angular/core' ;
77import { toBoolean , isBrowser } from '../../common' ;
88
9- import { MDCRippleAdapter } from './ripple- adapter' ;
9+ import { MDCRippleAdapter } from './adapter' ;
1010import { supportsCssVariables } from '@material/ripple/util' ;
1111import { MDCRippleFoundation } from '@material/ripple' ;
1212
1313@Injectable ( )
1414export class MdcRipple implements OnDestroy {
15- interactionListenerFn : ( ) => void ;
16- resizeListenerFn : ( ) => void ;
17- private disabled_ : boolean ;
15+ private _interactionListenerFn : ( ) => void ;
16+ private _resizeListenerFn : ( ) => void ;
17+ private _disabled : boolean = false ;
1818
1919 unbounded : boolean ;
2020 active : boolean ;
21- get disabled ( ) { return this . disabled_ ; }
21+ get disabled ( ) { return this . _disabled ; }
2222 set disabled ( value ) {
23- this . disabled_ = toBoolean ( value ) ;
24- if ( this . disabled_ ) {
25- this . _foundation . deactivate ( ) ;
23+ this . _disabled = toBoolean ( value ) ;
24+ if ( this . _disabled ) {
25+ this . _foundation . destroy ( ) ;
2626 } else {
27- this . _foundation . activate ( ) ;
27+ this . _foundation . init ( ) ;
2828 }
2929 }
3030
@@ -33,39 +33,37 @@ export class MdcRipple implements OnDestroy {
3333 isUnbounded : ( ) => this . unbounded ,
3434 isSurfaceActive : ( ) => this . active ,
3535 isSurfaceDisabled : ( ) => {
36- return ( this . _root . nativeElement . attributes . getNamedItem ( 'disabled' ) || this . disabled ) ? true : false ;
36+ return ( this . elementRef . nativeElement . attributes . getNamedItem ( 'disabled' ) || this . disabled ) ? true : false ;
3737 } ,
3838 addClass : ( className : string ) => {
39- this . _renderer . addClass ( this . _root . nativeElement , className ) ;
39+ this . _renderer . addClass ( this . elementRef . nativeElement , className ) ;
4040 } ,
4141 removeClass : ( className : string ) => {
42- this . _renderer . removeClass ( this . _root . nativeElement , className ) ;
42+ this . _renderer . removeClass ( this . elementRef . nativeElement , className ) ;
4343 } ,
4444 registerInteractionHandler : ( evtType : string , handler : EventListener ) => {
45- this . resizeListenerFn = this . _renderer . listen ( this . _root . nativeElement , evtType , handler ) ;
45+ this . _resizeListenerFn = this . _renderer . listen ( this . elementRef . nativeElement , evtType , handler ) ;
4646 } ,
4747 deregisterInteractionHandler : ( evtType : string , handler : EventListener ) => {
48- if ( this . interactionListenerFn ) {
49- this . interactionListenerFn ( ) ;
48+ if ( this . _interactionListenerFn ) {
49+ this . _interactionListenerFn ( ) ;
5050 }
5151 } ,
5252 registerResizeHandler : ( handler : EventListener ) => {
5353 if ( isBrowser ( ) ) {
54- this . resizeListenerFn = this . _renderer . listen ( window , 'resize' , handler ) ;
54+ this . _resizeListenerFn = this . _renderer . listen ( window , 'resize' , handler ) ;
5555 }
5656 } ,
5757 deregisterResizeHandler : ( handler : EventListener ) => {
58- if ( isBrowser ( ) && this . resizeListenerFn ) {
59- this . resizeListenerFn ( ) ;
58+ if ( isBrowser ( ) && this . _resizeListenerFn ) {
59+ this . _resizeListenerFn ( ) ;
6060 }
6161 } ,
6262 updateCssVariable : ( varName : string , value : string ) => {
63- if ( this . _root ) {
64- this . _root . nativeElement . style . setProperty ( varName , value ) ;
65- }
63+ this . elementRef . nativeElement . style . setProperty ( varName , value ) ;
6664 } ,
6765 computeBoundingRect : ( ) => {
68- const { left, top, height, width } = this . _root . nativeElement . getBoundingClientRect ( ) ;
66+ const { left, top, height, width } = this . elementRef . nativeElement . getBoundingClientRect ( ) ;
6967 return {
7068 top,
7169 left,
@@ -93,7 +91,7 @@ export class MdcRipple implements OnDestroy {
9391
9492 constructor (
9593 private _renderer : Renderer2 ,
96- private _root : ElementRef ) {
94+ public elementRef : ElementRef ) {
9795 }
9896
9997 ngOnDestroy ( ) {
@@ -105,15 +103,23 @@ export class MdcRipple implements OnDestroy {
105103 this . unbounded = unbounded ;
106104 }
107105
108- activate ( ) : void {
109- this . _foundation . activate ( ) ;
106+ activate ( event ?: Event ) : void {
107+ this . _foundation . activate ( event ) ;
110108 }
111109
112- deactivate ( ) : void {
113- this . _foundation . deactivate ( ) ;
110+ deactivate ( event ?: Event ) : void {
111+ this . _foundation . deactivate ( event ) ;
114112 }
115113
116114 layout ( ) : void {
117115 this . _foundation . layout ( ) ;
118116 }
117+
118+ isSurfaceDisabled ( ) : boolean {
119+ return this . _mdcAdapter . isSurfaceDisabled ( ) ;
120+ }
121+
122+ isSurfaceActive ( ) : boolean {
123+ return this . _mdcAdapter . isSurfaceActive ( ) ;
124+ }
119125}
0 commit comments