File tree 1 file changed +43
-19
lines changed
1 file changed +43
-19
lines changed Original file line number Diff line number Diff line change 1037
1037
containerTop = this . element . offset ( ) . top - this . container . outerHeight ( ) - parentOffset . top ;
1038
1038
else
1039
1039
containerTop = this . element . offset ( ) . top + this . element . outerHeight ( ) - parentOffset . top ;
1040
+
1041
+ // Force the container to it's actual width
1042
+ this . container . css ( {
1043
+ top : 0 ,
1044
+ left : 0 ,
1045
+ right : 'auto'
1046
+ } ) ;
1047
+ var containerWidth = this . container . outerWidth ( ) ;
1048
+
1040
1049
this . container [ this . drops == 'up' ? 'addClass' : 'removeClass' ] ( 'drop-up' ) ;
1041
1050
1042
1051
if ( this . opens == 'left' ) {
1043
- this . container . css ( {
1044
- top : containerTop ,
1045
- right : parentRightEdge - this . element . offset ( ) . left - this . element . outerWidth ( ) ,
1046
- left : 'auto'
1047
- } ) ;
1048
- if ( this . container . offset ( ) . left < 0 ) {
1052
+ var containerRight = parentRightEdge - this . element . offset ( ) . left - this . element . outerWidth ( ) ;
1053
+ if ( containerWidth + containerRight > $ ( window ) . width ( ) ) {
1049
1054
this . container . css ( {
1055
+ top : containerTop ,
1050
1056
right : 'auto' ,
1051
1057
left : 9
1052
1058
} ) ;
1059
+ } else {
1060
+ this . container . css ( {
1061
+ top : containerTop ,
1062
+ right : containerRight ,
1063
+ left : 'auto'
1064
+ } ) ;
1053
1065
}
1054
1066
} else if ( this . opens == 'center' ) {
1055
- this . container . css ( {
1056
- top : containerTop ,
1057
- left : this . element . offset ( ) . left - parentOffset . left + this . element . outerWidth ( ) / 2
1058
- - this . container . outerWidth ( ) / 2 ,
1059
- right : 'auto'
1060
- } ) ;
1061
- if ( this . container . offset ( ) . left < 0 ) {
1067
+ var containerLeft = this . element . offset ( ) . left - parentOffset . left + this . element . outerWidth ( ) / 2
1068
+ - containerWidth / 2 ;
1069
+ if ( containerLeft < 0 ) {
1062
1070
this . container . css ( {
1071
+ top : containerTop ,
1063
1072
right : 'auto' ,
1064
1073
left : 9
1065
1074
} ) ;
1075
+ } else if ( containerLeft + containerWidth > $ ( window ) . width ( ) ) {
1076
+ this . container . css ( {
1077
+ top : containerTop ,
1078
+ left : 'auto' ,
1079
+ right : 0
1080
+ } ) ;
1081
+ } else {
1082
+ this . container . css ( {
1083
+ top : containerTop ,
1084
+ left : containerLeft ,
1085
+ right : 'auto'
1086
+ } ) ;
1066
1087
}
1067
1088
} else {
1068
- this . container . css ( {
1069
- top : containerTop ,
1070
- left : this . element . offset ( ) . left - parentOffset . left ,
1071
- right : 'auto'
1072
- } ) ;
1073
- if ( this . container . offset ( ) . left + this . container . outerWidth ( ) > $ ( window ) . width ( ) ) {
1089
+ var containerLeft = this . element . offset ( ) . left - parentOffset . left ;
1090
+ if ( containerLeft + containerWidth > $ ( window ) . width ( ) ) {
1074
1091
this . container . css ( {
1092
+ top : containerTop ,
1075
1093
left : 'auto' ,
1076
1094
right : 0
1077
1095
} ) ;
1096
+ } else {
1097
+ this . container . css ( {
1098
+ top : containerTop ,
1099
+ left : containerLeft ,
1100
+ right : 'auto'
1101
+ } ) ;
1078
1102
}
1079
1103
}
1080
1104
} ,
You can’t perform that action at this time.
0 commit comments