@ -219,9 +219,9 @@
} ,
} ,
isRightSpaceEnough : function ( combo , popup , extraWidth ) {
isRightSpaceEnough : function ( combo , popup , extraWidth ) {
var viewBounds = popup . element . bounds ( ) ,
var viewBounds = popup . element [ 0 ] . getBoundingClientRect ( ) ,
windowBounds = BI . Widget . _renderEngine . createElement ( "body" ) . bounds ( ) ;
viewportBounds = document . documentElement . getBoundingClientRect ( ) ;
return BI . DOM . getRightPosition ( combo , popup , extraWidth ) . left + viewBounds . width <= window Bounds. width ;
return BI . DOM . getRightPosition ( combo , popup , extraWidth ) . left + viewBounds . width <= viewport Bounds. width ;
} ,
} ,
isInnerRightSpaceEnough : function ( combo , popup , extraWidth ) {
isInnerRightSpaceEnough : function ( combo , popup , extraWidth ) {
@ -233,9 +233,9 @@
} ,
} ,
isBottomSpaceEnough : function ( combo , popup , extraHeight ) {
isBottomSpaceEnough : function ( combo , popup , extraHeight ) {
var viewBounds = popup . element . bounds ( ) ,
var viewBounds = popup . element [ 0 ] . getBoundingClientRect ( ) ,
windowBounds = BI . Widget . _renderEngine . createElement ( "body" ) . bounds ( ) ;
viewportBounds = document . documentElement . getBoundingClientRect ( ) ;
return BI . DOM . getBottomPosition ( combo , popup , extraHeight ) . top + viewBounds . height <= window Bounds. height ;
return BI . DOM . getBottomPosition ( combo , popup , extraHeight ) . top + viewBounds . height <= viewport Bounds. height ;
} ,
} ,
isRightSpaceLarger : function ( combo ) {
isRightSpaceLarger : function ( combo ) {
@ -318,23 +318,24 @@
getTopAlignPosition : function ( combo , popup , extraHeight , needAdaptHeight , container ) {
getTopAlignPosition : function ( combo , popup , extraHeight , needAdaptHeight , container ) {
var comboOffset = combo . element . offset ( ) ;
var comboOffset = combo . element . offset ( ) ;
var comboBounds = combo . element . bounds ( ) , popupBounds = popup . element . bounds ( ) ,
var comboBounds = combo . element [ 0 ] . getBoundingClientRect ( ) ,
windowBounds = BI . Widget . _renderEngine . createElement ( "body" ) . bounds ( ) ,
popupBounds = popup . element [ 0 ] . getBoundingClientRect ( ) ,
viewportBounds = document . documentElement . getBoundingClientRect ( ) ,
containerBounds = container ? container . getBoundingClientRect ( ) : { top : 0 } ;
containerBounds = container ? container . getBoundingClientRect ( ) : { top : 0 } ;
var top , adaptHeight , dir ;
var top , adaptHeight , dir ;
if ( BI . DOM . isBottomSpaceEnough ( combo , popup , - 1 * comboBounds . height + extraHeight ) ) {
if ( BI . DOM . isBottomSpaceEnough ( combo , popup , - 1 * comboBounds . height + extraHeight ) ) {
top = comboOffset . top - containerBounds . top + extraHeight ;
top = comboOffset . top - containerBounds . top + extraHeight ;
} else if ( needAdaptHeight ) {
} else if ( needAdaptHeight ) {
top = comboOffset . top + extraHeight ;
top = comboBounds . top - containerBounds . top + extraHeight ;
adaptHeight = window Bounds. height - top ;
adaptHeight = viewport Bounds. height - top ;
} else if ( BI . DOM . isTopSpaceEnough ( combo , popup , - 1 * comboBounds . height + extraHeight ) ) {
} else if ( BI . DOM . isTopSpaceEnough ( combo , popup , - 1 * comboBounds . height + extraHeight ) ) {
// 下方空间不足且不允许调整高度的情况下,优先使用上对齐
// 下方空间不足且不允许调整高度的情况下,优先使用上对齐
top = comboOffset . top + comboBounds . height - popupBounds . height - extraHeight ;
top = comboBounds . top + comboBounds . height - popupBounds . height - containerBounds . top - extraHeight ;
dir = "top" ;
dir = "top" ;
} else {
} else {
top = window Bounds. height - popupBounds . height ;
top = viewport Bounds. height - popupBounds . height ;
if ( top < extraHeight ) {
if ( top < extraHeight ) {
adaptHeight = window Bounds. height - extraHeight ;
adaptHeight = viewport Bounds. height - extraHeight ;
}
}
}
}
if ( top < extraHeight ) {
if ( top < extraHeight ) {
@ -383,11 +384,11 @@
if ( BI . DOM . isTopSpaceEnough ( combo , popup , - 1 * comboBounds . height + extraHeight ) ) {
if ( BI . DOM . isTopSpaceEnough ( combo , popup , - 1 * comboBounds . height + extraHeight ) ) {
top = comboOffset . top + comboBounds . height - containerBounds . top - popupBounds . height ;
top = comboOffset . top + comboBounds . height - containerBounds . top - popupBounds . height ;
} else if ( needAdaptHeight ) {
} else if ( needAdaptHeight ) {
top = 0 ;
top = 0 - containerBounds . top ;
adaptHeight = comboOffset . top + comboBounds . height - extraHeight ;
adaptHeight = comboBounds . top + comboBounds . height - extraHeight ;
} else if ( BI . DOM . isBottomSpaceEnough ( combo , popup , - 1 * comboBounds . height + extraHeight ) ) {
} else if ( BI . DOM . isBottomSpaceEnough ( combo , popup , - 1 * comboBounds . height + extraHeight ) ) {
// 上方空间不足且不允许调整高度的情况下,优先使用下对齐
// 上方空间不足且不允许调整高度的情况下,优先使用下对齐
top = comboOffset . top + extraHeight ;
top = comboOffset . top - containerBounds . top + extraHeight ;
dir = "bottom" ;
dir = "bottom" ;
} else {
} else {
top = 0 ;
top = 0 ;
@ -395,7 +396,7 @@
adaptHeight = windowBounds . height - extraHeight ;
adaptHeight = windowBounds . height - extraHeight ;
}
}
}
}
if ( top < 0 ) {
if ( top + containerBounds . top < 0 ) {
top = 0 ;
top = 0 ;
}
}
return adaptHeight ? {
return adaptHeight ? {