File tree Expand file tree Collapse file tree 3 files changed +43
-1
lines changed Expand file tree Collapse file tree 3 files changed +43
-1
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ export class OverlayRef implements PortalHost {
23
23
}
24
24
25
25
let attachResult = this . _portalHost . attach ( portal ) ;
26
+ this . updateSize ( ) ;
26
27
this . updatePosition ( ) ;
27
28
28
29
return attachResult ;
@@ -58,6 +59,17 @@ export class OverlayRef implements PortalHost {
58
59
}
59
60
}
60
61
62
+ /** Updates the size of the overlay based on the overlay config. */
63
+ updateSize ( ) {
64
+ if ( this . _state . width ) {
65
+ this . _pane . style . width = `${ this . _state . width } px` ;
66
+ }
67
+
68
+ if ( this . _state . height ) {
69
+ this . _pane . style . height = `${ this . _state . height } px` ;
70
+ }
71
+ }
72
+
61
73
/** Attaches a backdrop for this overlay. */
62
74
private _attachBackdrop ( ) {
63
75
this . _backdropElement = document . createElement ( 'div' ) ;
Original file line number Diff line number Diff line change @@ -12,10 +12,16 @@ export class OverlayState {
12
12
/** Whether the overlay has a backdrop. */
13
13
hasBackdrop : boolean = false ;
14
14
15
+ /** Custom class to add to the backdrop **/
15
16
backdropClass : string = 'md-overlay-dark-backdrop' ;
16
17
18
+ /** The width of the overlay panel **/
19
+ width : number ;
20
+
21
+ /** The height of the overlay panel **/
22
+ height : number ;
23
+
17
24
// TODO(jelbourn): configuration still to add
18
- // - overlay size
19
25
// - focus trap
20
26
// - disable pointer events
21
27
// - z-index
Original file line number Diff line number Diff line change @@ -98,6 +98,30 @@ describe('Overlay', () => {
98
98
} ) ;
99
99
} ) ;
100
100
101
+ describe ( 'size' , ( ) => {
102
+ let state : OverlayState ;
103
+
104
+ beforeEach ( ( ) => {
105
+ state = new OverlayState ( ) ;
106
+ } ) ;
107
+
108
+ it ( 'should apply the width set in the config' , ( ) => {
109
+ state . width = 500 ;
110
+
111
+ overlay . create ( state ) . attach ( componentPortal ) ;
112
+ const pane = ( < HTMLElement > overlayContainerElement . children [ 0 ] ) ;
113
+ expect ( pane . style . width ) . toEqual ( '500px' ) ;
114
+ } ) ;
115
+
116
+ it ( 'should apply the height set in the config' , ( ) => {
117
+ state . height = 500 ;
118
+
119
+ overlay . create ( state ) . attach ( componentPortal ) ;
120
+ const pane = ( < HTMLElement > overlayContainerElement . children [ 0 ] ) ;
121
+ expect ( pane . style . height ) . toEqual ( '500px' ) ;
122
+ } ) ;
123
+ } ) ;
124
+
101
125
describe ( 'backdrop' , ( ) => {
102
126
let config : OverlayState ;
103
127
You can’t perform that action at this time.
0 commit comments