@@ -12,30 +12,30 @@ declare global {
1212export interface ResizeDefaults {
1313 widthSensitive ?: boolean ;
1414 heightSensitive ?: boolean ;
15- debounceTimeout ?: number ;
15+ debounceTimeout ?: number ;
1616 injectionFactories ?: string [ ] ;
1717}
1818
1919class ResizeService extends Service . extend ( Evented , {
20- debounceTimeout : computed . oneWay ( 'defaultDebounceTimeout' ) ,
21- heightSensitive : computed . oneWay ( 'defaultHeightSensitive' ) ,
22- screenHeight : computed . readOnly ( '_oldHeight' ) ,
23- screenWidth : computed . readOnly ( '_oldWidth' ) ,
24- widthSensitive : computed . oneWay ( 'defaultWidthSensitive' ) ,
20+ debounceTimeout : computed . oneWay ( 'defaultDebounceTimeout' ) ,
21+ heightSensitive : computed . oneWay ( 'defaultHeightSensitive' ) ,
22+ screenHeight : computed . readOnly ( '_oldHeight' ) ,
23+ screenWidth : computed . readOnly ( '_oldWidth' ) ,
24+ widthSensitive : computed . oneWay ( 'defaultWidthSensitive' )
2525} ) {
2626 public _oldWidth = window . innerWidth ;
2727 public _oldHeight = window . innerHeight ;
2828 public _oldWidthDebounced = window . innerWidth ;
2929 public _oldHeightDebounced = window . innerHeight ;
3030
31- public resizeServiceDefaults ! : ResizeDefaults ;
31+ public resizeServiceDefaults ! : Partial < ResizeDefaults > ;
3232
3333 public _onResizeHandler ?: ( this : Window , evt : UIEvent ) => void ;
3434 public _scheduledDebounce ?: ReturnType < typeof debounce > ;
3535 constructor ( ) {
3636 super ( ...arguments ) ;
3737 this . _setDefaults ( ) ;
38- this . _onResizeHandler = ( evt ) => {
38+ this . _onResizeHandler = evt => {
3939 this . _fireResizeNotification ( evt ) ;
4040 const scheduledDebounce = debounce ( this , this . _fireDebouncedResizeNotification , evt , this . get ( 'debounceTimeout' ) ) ;
4141 this . _scheduledDebounce = scheduledDebounce ;
@@ -55,9 +55,9 @@ class ResizeService extends Service.extend(Evented, {
5555 }
5656
5757 public _setDefaults ( ) {
58- const defaults = getWithDefault ( this , 'resizeServiceDefaults' , { } ) ;
58+ const defaults = getWithDefault ( this , 'resizeServiceDefaults' , { } as any ) ;
5959
60- Object . keys ( defaults ) . map ( ( key : keyof ResizeDefaults ) => {
60+ Object . keys ( defaults ) . map ( ( key : keyof ResizeDefaults ) => {
6161 const classifiedKey = classify ( key ) ;
6262 const defaultKey = `default${ classifiedKey } ` ;
6363 return set ( this as any , defaultKey , defaults [ key ] ) ;
@@ -68,8 +68,7 @@ class ResizeService extends Service.extend(Evented, {
6868 const wKey = debounced ? '_oldWidthDebounced' : '_oldWidth' ;
6969 const hKey = debounced ? '_oldHeightDebounced' : '_oldHeight' ;
7070 return (
71- ( this . get ( 'widthSensitive' ) && w !== this . get ( wKey ) ) ||
72- ( this . get ( 'heightSensitive' ) && h !== this . get ( hKey ) )
71+ ( this . get ( 'widthSensitive' ) && w !== this . get ( wKey ) ) || ( this . get ( 'heightSensitive' ) && h !== this . get ( hKey ) )
7372 ) ;
7473 }
7574
@@ -81,17 +80,23 @@ class ResizeService extends Service.extend(Evented, {
8180 }
8281
8382 public _installResizeListener ( ) {
84- if ( ! this . _onResizeHandler ) { return ; }
83+ if ( ! this . _onResizeHandler ) {
84+ return ;
85+ }
8586 window . addEventListener ( 'resize' , this . _onResizeHandler ) ;
8687 }
8788
8889 public _uninstallResizeListener ( ) {
89- if ( ! this . _onResizeHandler ) { return ; }
90+ if ( ! this . _onResizeHandler ) {
91+ return ;
92+ }
9093 window . removeEventListener ( 'resize' , this . _onResizeHandler ) ;
9194 }
9295
9396 public _cancelScheduledDebounce ( ) {
94- if ( ! this . _scheduledDebounce ) { return ; }
97+ if ( ! this . _scheduledDebounce ) {
98+ return ;
99+ }
95100 cancel ( this . _scheduledDebounce ) ;
96101 }
97102
0 commit comments