This repository was archived by the owner on Mar 13, 2018. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed
Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change 249249 }
250250 } ,
251251 positionTarget : function ( ) {
252- var computedStyle = getComputedStyle ( this . target ) ;
253- if ( this . opened && computedStyle . top === 'auto' && computedStyle . bottom === 'auto' ) {
254- this . target . style . top = ( ( window . innerHeight - this . target . getBoundingClientRect ( ) . height ) / 2 ) + 'px' ;
252+ if ( this . opened ) {
253+ // vertically and horizontally center if not positioned
254+ var computedStyle = getComputedStyle ( this . target ) ;
255+ if ( computedStyle . top === 'auto' && computedStyle . bottom === 'auto' ) {
256+ this . target . style . top = ( ( window . innerHeight - this . target . getBoundingClientRect ( ) . height ) / 2 ) + 'px' ;
257+ }
258+ if ( computedStyle . left === 'auto' && computedStyle . right === 'auto' ) {
259+ this . target . style . left = ( ( window . innerWidth - this . target . getBoundingClientRect ( ) . width ) / 2 ) + 'px' ;
260+ }
255261 }
256262 } ,
263+ resetTargetPosition : function ( ) {
264+ this . target . style . top = this . target . style . left = null ;
265+ } ,
257266 renderOpened : function ( ) {
258267 this . target . classList . remove ( 'closing' ) ;
259268 this . target . classList . add ( 'revealed' ) ;
272281 this . animating = null ;
273282 this . target . classList . remove ( 'closing' ) ;
274283 this . target . classList . toggle ( 'revealed' , this . opened ) ;
284+ if ( ! this . opened ) {
285+ this . resetTargetPosition ( ) ;
286+ }
275287 this . applyFocus ( ) ;
276288 } ,
277289 openedAnimationEnd : function ( e ) {
You can’t perform that action at this time.
0 commit comments