@@ -2602,6 +2602,11 @@ angular.module('ui.bootstrap.modal', [])
2602
2602
var $modalStack = {
2603
2603
NOW_CLOSING_EVENT : 'modal.stack.now-closing'
2604
2604
} ;
2605
+
2606
+ var bodyPad = 0 ;
2607
+ var scrollBarWidth = 0 ;
2608
+ var body = $document [ 0 ] . body ;
2609
+ var fixedElements = angular . element ( body . querySelector ( '.navbar-fixed-top, .navbar-fixed-bottom, .affix' ) ) ;
2605
2610
2606
2611
//Modal focus behavior
2607
2612
var focusableElementList ;
@@ -2627,7 +2632,28 @@ angular.module('ui.bootstrap.modal', [])
2627
2632
}
2628
2633
} ) ;
2629
2634
2635
+ function checkScrollBar ( ) {
2636
+ if ( body . clientWidth >= window . innerWidth ) { return ; }
2637
+ measureScrollBar ( ) ;
2638
+ }
2639
+
2640
+ function measureScrollBar ( ) {
2641
+ scrollBarWidth = window . innerWidth - body . clientWidth ;
2642
+ bodyPad = parseInt ( ( angular . element ( body ) . css ( 'padding-right' ) || 0 ) , 10 ) ;
2643
+ }
2644
+
2645
+ function setScrollBar ( ) {
2646
+ angular . element ( body ) . css ( 'padding-right' , bodyPad + scrollBarWidth + 'px' ) ;
2647
+ fixedElements . css ( 'padding-right' , bodyPad + scrollBarWidth + 'px' ) ;
2648
+ }
2649
+
2650
+ function resetScrollBar ( ) {
2651
+ angular . element ( body ) . css ( 'padding-right' , bodyPad + 'px' ) ;
2652
+ fixedElements . css ( 'padding-right' , bodyPad + 'px' ) ;
2653
+ }
2654
+
2630
2655
function removeModalWindow ( modalInstance , elementToReceiveFocus ) {
2656
+
2631
2657
var body = $document . find ( 'body' ) . eq ( 0 ) ;
2632
2658
var modalWindow = openedWindows . get ( modalInstance ) . value ;
2633
2659
@@ -2638,7 +2664,11 @@ angular.module('ui.bootstrap.modal', [])
2638
2664
var modalBodyClass = modalWindow . openedClass || OPENED_MODAL_CLASS ;
2639
2665
openedClasses . remove ( modalBodyClass , modalInstance ) ;
2640
2666
body . toggleClass ( modalBodyClass , openedClasses . hasKey ( modalBodyClass ) ) ;
2667
+ if ( scrollBarWidth ) {
2668
+ resetScrollBar ( ) ;
2669
+ }
2641
2670
} ) ;
2671
+
2642
2672
checkRemoveBackdrop ( ) ;
2643
2673
2644
2674
//move focus to specified element if available, or else to body
@@ -2771,7 +2801,10 @@ angular.module('ui.bootstrap.modal', [])
2771
2801
body . append ( backdropDomEl ) ;
2772
2802
}
2773
2803
2804
+ checkScrollBar ( ) ;
2805
+
2774
2806
var angularDomEl = angular . element ( '<div modal-window="modal-window"></div>' ) ;
2807
+
2775
2808
angularDomEl . attr ( {
2776
2809
'template-url' : modal . windowTemplateUrl ,
2777
2810
'window-class' : modal . windowClass ,
@@ -2789,6 +2822,10 @@ angular.module('ui.bootstrap.modal', [])
2789
2822
body . append ( modalDomEl ) ;
2790
2823
body . addClass ( modalBodyClass ) ;
2791
2824
2825
+ if ( scrollBarWidth && currBackdropIndex === 0 ) {
2826
+ setScrollBar ( ) ;
2827
+ }
2828
+
2792
2829
$modalStack . clearFocusListCache ( ) ;
2793
2830
} ;
2794
2831
@@ -5833,4 +5870,4 @@ angular.module("template/typeahead/typeahead-popup.html", []).run(["$templateCac
5833
5870
"</ul>\n" +
5834
5871
"" ) ;
5835
5872
} ] ) ;
5836
- ! angular . $$csp ( ) && angular . element ( document ) . find ( 'head' ) . prepend ( '<style type="text/css">.ng-animate.item:not(.left):not(.right){-webkit-transition:0s ease-in-out left;transition:0s ease-in-out left}</style>' ) ;
5873
+ ! angular . $$csp ( ) && angular . element ( document ) . find ( 'head' ) . prepend ( '<style type="text/css">.ng-animate.item:not(.left):not(.right){-webkit-transition:0s ease-in-out left;transition:0s ease-in-out left}</style>' ) ;
0 commit comments