Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

Commit b642c01

Browse files
committed
fix(modal): clean up paddings for modal window
Set modal window padding after modal is rendered. Remove unnecessary null checks. Set modal padding properties only when required. Closes #3714
1 parent 93d4133 commit b642c01

File tree

1 file changed

+28
-27
lines changed

1 file changed

+28
-27
lines changed

src/modal/modal.js

+28-27
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)