@@ -151,33 +151,6 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.stackedMap'])
151151 element . addClass ( attrs . windowTopClass || '' ) ;
152152 scope . size = attrs . size ;
153153
154- // get topmost modal object
155- var bodyIsOverflowing ;
156- var modal = $modalStack . getTop ( ) ;
157-
158- // only when modal is attached to body
159- if ( modal && modal . value && modal . value . appendTo === 'body' ) {
160-
161- // check bodyOverflowing property that was set when opening modal
162- if ( modal . value . modalDomEl && modal . value . modalDomEl . bodyOverflowing ) {
163- bodyIsOverflowing = true ;
164- }
165-
166- // start - from adjustDialog method of modal.js of bootstrap
167- // check if modal is overflowing
168- var modalIsOverflowing = element [ 0 ] . scrollHeight > document . documentElement . clientHeight ;
169-
170- if ( ! $$scrollbarHelper . scrollbarWidth ) {
171- $$scrollbarHelper . measureScrollbar ( ) ;
172- }
173-
174- element . css ( {
175- 'padding-left' : ( ! bodyIsOverflowing && modalIsOverflowing ? $$scrollbarHelper . scrollbarWidth : '' ) + 'px' ,
176- 'padding-right' : ( bodyIsOverflowing && ! modalIsOverflowing ? $$scrollbarHelper . scrollbarWidth : '' ) + 'px'
177- } ) ;
178- // end - from adjustDialog method of modal.js of bootstrap
179- }
180-
181154 scope . close = function ( evt ) {
182155 var modal = $modalStack . getTop ( ) ;
183156 if ( modal && modal . value . backdrop && modal . value . backdrop !== 'static' && ( evt . target === evt . currentTarget ) ) {
@@ -251,6 +224,34 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.stackedMap'])
251224 var modal = $modalStack . getTop ( ) ;
252225 if ( modal ) {
253226 $modalStack . modalRendered ( modal . key ) ;
227+
228+ // get topmost modal object
229+ var bodyIsOverflowing ;
230+ var modalIsOverflowing ;
231+
232+ // only when modal is attached to body
233+ if ( modal . value . appendTo === 'body' ) {
234+
235+ // check bodyOverflowing property that was set when opening modal
236+ if ( modal . value . modalDomEl . bodyOverflowing ) {
237+ bodyIsOverflowing = true ;
238+ }
239+
240+ // start - from adjustDialog method of modal.js of bootstrap
241+ // check if modal is overflowing
242+ modalIsOverflowing = element [ 0 ] . scrollHeight > document . documentElement . clientHeight ;
243+
244+ if ( ! $$scrollbarHelper . scrollbarWidth ) {
245+ $$scrollbarHelper . measureScrollbar ( ) ;
246+ }
247+
248+ if ( modalIsOverflowing && ! bodyIsOverflowing ) {
249+ element . css ( 'padding-left' , $$scrollbarHelper . scrollbarWidth + 'px' ) ;
250+ } else if ( bodyIsOverflowing && ! modalIsOverflowing ) {
251+ element . css ( 'padding-right' , $$scrollbarHelper . scrollbarWidth + 'px' ) ;
252+ }
253+ // end - from adjustDialog method of modal.js of bootstrap
254+ }
254255 }
255256 } ) ;
256257 }
0 commit comments