@@ -738,9 +738,11 @@ MdPanelService.prototype.newPanelAnimation = function() {
738
738
MdPanelService . prototype . _wrapTemplate = function ( origTemplate ) {
739
739
var template = origTemplate || '' ;
740
740
741
+ // The panel should be initially rendered offscreen so we can calculate
742
+ // height and width for positioning.
741
743
return '' +
742
744
'<div class="md-panel-outer-wrapper">' +
743
- ' <div class="md-panel">' + template + '</div>' +
745
+ ' <div class="md-panel" style="left: -9999px;" >' + template + '</div>' +
744
746
'</div>' ;
745
747
} ;
746
748
@@ -1137,7 +1139,6 @@ MdPanelRef.prototype._createPanel = function() {
1137
1139
1138
1140
self . _configureTrapFocus ( ) ;
1139
1141
self . _addStyles ( ) . then ( function ( ) {
1140
- self . _panelContainer . addClass ( MD_PANEL_HIDDEN ) ;
1141
1142
resolve ( self ) ;
1142
1143
} , reject ) ;
1143
1144
} , reject ) ;
@@ -1156,23 +1157,30 @@ MdPanelRef.prototype._addStyles = function() {
1156
1157
self . _panelContainer . css ( 'z-index' , self . _config [ 'zIndex' ] ) ;
1157
1158
self . _panelEl . css ( 'z-index' , self . _config [ 'zIndex' ] + 1 ) ;
1158
1159
1160
+ var hideAndResolve = function ( ) {
1161
+ // Remove left: -9999px and add hidden class.
1162
+ self . _panelEl . css ( 'left' , '' ) ;
1163
+ self . _panelContainer . addClass ( MD_PANEL_HIDDEN ) ;
1164
+ resolve ( self ) ;
1165
+ } ;
1166
+
1159
1167
if ( self . _config [ 'fullscreen' ] ) {
1160
1168
self . _panelEl . addClass ( '_md-panel-fullscreen' ) ;
1161
- resolve ( self ) ;
1169
+ hideAndResolve ( ) ;
1162
1170
return ; // Don't setup positioning.
1163
1171
}
1164
1172
1165
1173
var positionConfig = self . _config [ 'position' ] ;
1166
1174
if ( ! positionConfig ) {
1167
- resolve ( self ) ;
1175
+ hideAndResolve ( ) ;
1168
1176
return ; // Don't setup positioning.
1169
1177
}
1170
1178
1171
1179
// Wait for angular to finish processing the template, then position it
1172
1180
// correctly. This is necessary so that the panel will have a defined height
1173
1181
// and width.
1174
1182
self . _$rootScope [ '$$postDigest' ] ( function ( ) {
1175
- self . _updatePosition ( ) ;
1183
+ self . _updatePosition ( true ) ;
1176
1184
resolve ( self ) ;
1177
1185
} ) ;
1178
1186
} ) ;
@@ -1181,13 +1189,20 @@ MdPanelRef.prototype._addStyles = function() {
1181
1189
1182
1190
/**
1183
1191
* Calculates and updates the position of the panel.
1192
+ * @param {boolean= } opt_init
1184
1193
* @private
1185
1194
*/
1186
- MdPanelRef . prototype . _updatePosition = function ( ) {
1195
+ MdPanelRef . prototype . _updatePosition = function ( opt_init ) {
1187
1196
var positionConfig = this . _config [ 'position' ] ;
1188
1197
1189
1198
if ( positionConfig ) {
1190
1199
positionConfig . _setPanelPosition ( this . _panelEl ) ;
1200
+
1201
+ // Hide the panel now that position is known.
1202
+ if ( opt_init ) {
1203
+ this . _panelContainer . addClass ( MD_PANEL_HIDDEN ) ;
1204
+ }
1205
+
1191
1206
this . _panelEl . css ( 'top' , positionConfig . getTop ( ) ) ;
1192
1207
this . _panelEl . css ( 'bottom' , positionConfig . getBottom ( ) ) ;
1193
1208
this . _panelEl . css ( 'left' , positionConfig . getLeft ( ) ) ;
0 commit comments