@@ -4,13 +4,11 @@ import { fadeOut, fadeIn } from '../animations/main';
4
4
import { IgxSelectBase } from './select.common' ;
5
5
import { isIE } from '../core/utils' ;
6
6
import { BaseFitPositionStrategy } from '../services/overlay/position/base-fit-position-strategy' ;
7
- import { DisplayDensity } from '../core/density' ;
8
7
9
8
/** @hidden @internal */
10
9
export class SelectPositioningStrategy extends BaseFitPositionStrategy implements IPositionStrategy {
11
10
12
11
private _selectDefaultSettings = {
13
- target : this . select . getEditElement ( ) . getBoundingClientRect ( ) . top , // ** Use top target here and top item for positioning bellow **
14
12
horizontalDirection : HorizontalAlignment . Right ,
15
13
verticalDirection : VerticalAlignment . Bottom ,
16
14
horizontalStartPoint : HorizontalAlignment . Left ,
@@ -74,14 +72,14 @@ export class SelectPositioningStrategy extends BaseFitPositionStrategy implement
74
72
public itemIsInvisible ( selectFit : SelectFit ) {
75
73
// selected item is completely invisible
76
74
return Math . round ( selectFit . itemRect . top * 100 ) / 100 >=
77
- Math . round ( selectFit . dropDownList . getBoundingClientRect ( ) . bottom * 100 ) / 100 ||
75
+ Math . round ( this . select . scrollContainer . getBoundingClientRect ( ) . bottom * 100 ) / 100 ||
78
76
Math . round ( selectFit . itemRect . bottom * 100 ) / 100 <=
79
- Math . round ( selectFit . dropDownList . getBoundingClientRect ( ) . top * 100 ) / 100 ||
77
+ Math . round ( this . select . scrollContainer . getBoundingClientRect ( ) . top * 100 ) / 100 ||
80
78
// selected item is partially invisible at ddl bottom
81
79
Math . round ( selectFit . itemRect . top * 100 ) / 100 <=
82
- ( selectFit . dropDownList . getBoundingClientRect ( ) . bottom * 100 ) / 100 &&
80
+ ( this . select . scrollContainer . getBoundingClientRect ( ) . bottom * 100 ) / 100 &&
83
81
Math . round ( selectFit . itemRect . bottom * 100 ) / 100 >=
84
- ( selectFit . dropDownList . getBoundingClientRect ( ) . bottom * 100 ) / 100 ;
82
+ ( this . select . scrollContainer . getBoundingClientRect ( ) . bottom * 100 ) / 100 ;
85
83
}
86
84
87
85
private manageScrollToItem ( selectFit : SelectFit ) {
@@ -96,10 +94,10 @@ export class SelectPositioningStrategy extends BaseFitPositionStrategy implement
96
94
const itemPosition = this . calculateScrollPosition ( selectFit ) ;
97
95
if ( isIE ( ) ) {
98
96
setTimeout ( ( ) => {
99
- selectFit . dropDownList . scrollTop = ( itemPosition ) ;
97
+ this . select . scrollContainer . scrollTop = ( itemPosition ) ;
100
98
} , 1 ) ;
101
99
} else {
102
- selectFit . dropDownList . scrollTop = ( itemPosition ) ;
100
+ this . select . scrollContainer . scrollTop = ( itemPosition ) ;
103
101
}
104
102
return itemPosition ;
105
103
}
@@ -110,7 +108,7 @@ export class SelectPositioningStrategy extends BaseFitPositionStrategy implement
110
108
}
111
109
112
110
const elementRect = selectFit . itemRect ;
113
- const parentRect = selectFit . dropDownList . getBoundingClientRect ( ) ;
111
+ const parentRect = this . select . scrollContainer . getBoundingClientRect ( ) ;
114
112
const scrollPosition = elementRect . bottom - parentRect . bottom ;
115
113
return Math . floor ( scrollPosition ) ;
116
114
}
@@ -164,22 +162,20 @@ export class SelectPositioningStrategy extends BaseFitPositionStrategy implement
164
162
private calculateVariables ( selectFit : SelectFit ) {
165
163
selectFit . itemRect = this . getInteractionItemElement ( ) . getBoundingClientRect ( ) ;
166
164
selectFit . itemElement = this . getInteractionItemElement ( ) ;
167
- selectFit . dropDownList = this . select . scrollContainer ;
168
- selectFit . inputElement = this . select . getEditElement ( ) ;
169
- }
165
+ }
170
166
171
167
public calculateStyles ( selectFit : SelectFit ) : SelectStyles {
172
168
const styles : SelectStyles = { } ;
173
- const inputFontSize = window . getComputedStyle ( selectFit . inputElement ) . fontSize ;
169
+ const inputFontSize = window . getComputedStyle ( this . settings . target as Element ) . fontSize ;
174
170
const numericInputFontSize = parseFloat ( inputFontSize ) ;
175
171
const itemFontSize = window . getComputedStyle ( selectFit . itemElement ) . fontSize ;
176
172
const numericItemFontSize = parseFloat ( itemFontSize ) ;
177
173
const inputTextToInputTop = ( selectFit . targetRect . bottom - selectFit . targetRect . top - numericInputFontSize ) / 2 ;
178
174
const itemTextToItemTop = ( selectFit . itemRect . height - numericItemFontSize ) / 2 ;
179
175
// Adjust for input top padding
180
176
const negateInputPaddings = (
181
- parseFloat ( window . getComputedStyle ( selectFit . inputElement ) . paddingTop ) -
182
- parseFloat ( window . getComputedStyle ( selectFit . inputElement ) . paddingBottom )
177
+ parseFloat ( window . getComputedStyle ( this . settings . target as Element ) . paddingTop ) -
178
+ parseFloat ( window . getComputedStyle ( this . settings . target as Element ) . paddingBottom )
183
179
) / 2 ;
184
180
styles . itemTextToInputTextDiff = Math . ceil ( itemTextToItemTop - inputTextToInputTop + negateInputPaddings ) ;
185
181
@@ -224,21 +220,6 @@ export class SelectPositioningStrategy extends BaseFitPositionStrategy implement
224
220
}
225
221
226
222
export interface SelectFit extends ConnectedFit {
227
- contentElementRect ?: ClientRect ;
228
- targetRect ?: ClientRect ;
229
- viewPortRect ?: ClientRect ;
230
- fitHorizontal ?: boolean ;
231
- fitVertical ?: boolean ;
232
- left ?: number ;
233
- right ?: number ;
234
- top ?: number ;
235
- bottom ?: number ;
236
- horizontalOffset ?: number ;
237
- verticalOffset ?: number ;
238
-
239
- // New properties
240
- inputElement ?: HTMLElement ;
241
- dropDownList ?: HTMLElement ;
242
223
itemElement ?: HTMLElement ;
243
224
itemRect ?: ClientRect ;
244
225
styles ?: SelectStyles ;
@@ -249,7 +230,6 @@ export interface SelectStyles {
249
230
itemTextIndent ?: number ;
250
231
itemTextToInputTextDiff ?: number ;
251
232
contentElementNewWidth ?: number ;
252
- displayDensity ?: DisplayDensity | string ;
253
233
numericLeftPadding ?: number ;
254
234
}
255
235
0 commit comments