@@ -46,13 +46,13 @@ export class SelectPositioningStrategy extends BaseFitPositionStrategy implement
46
46
} ;
47
47
48
48
if ( initialCall ) {
49
+ // Fill in the required selectFit object properties.
49
50
selectFit . viewPortRect = Util . getViewportRect ( document ) ;
51
+ selectFit . itemRect = this . getInteractionItemElement ( ) . getBoundingClientRect ( ) ;
52
+ selectFit . itemElement = this . getInteractionItemElement ( ) ;
50
53
51
- // Fill in the required selectFit object properties.
52
- this . calculateVariables ( selectFit ) ;
53
54
// Calculate input and selected item elements style related variables
54
55
selectFit . styles = this . calculateStyles ( selectFit ) ;
55
- selectFit . viewPortRect = Util . getViewportRect ( document ) ;
56
56
57
57
// Calculate how much to offset the overlay container.
58
58
this . calculateYoffset ( selectFit ) ;
@@ -100,17 +100,6 @@ export class SelectPositioningStrategy extends BaseFitPositionStrategy implement
100
100
return scrollAmount ;
101
101
}
102
102
103
- private calculateScrollPosition ( selectFit : SelectFit ) : number {
104
- if ( ! selectFit . itemElement ) { // this check may not be necessary
105
- return 0 ;
106
- }
107
-
108
- const elementRect = selectFit . itemRect ;
109
- const parentRect = this . select . scrollContainer . getBoundingClientRect ( ) ;
110
- const scrollPosition = elementRect . bottom - parentRect . bottom ;
111
- return Math . floor ( scrollPosition ) ;
112
- }
113
-
114
103
// Position the items outer container Below or Above the input.
115
104
fitInViewport ( contentElement : HTMLElement , selectFit : SelectFit ) {
116
105
// Position Select component's container below target/input as preferred positioning over above target/input
@@ -121,12 +110,10 @@ export class SelectPositioningStrategy extends BaseFitPositionStrategy implement
121
110
// Position Select component's container below target/input as preferred positioning over above target/input
122
111
if ( canFitBelowInput || ! canFitAboveInput ) {
123
112
// Calculate container starting point;
124
- // TODO: modify the yOffset instead & use one call to super.setStyle
125
113
selectFit . top = selectFit . targetRect . top - selectFit . styles . itemTextToInputTextDiff ;
126
114
127
115
} else {
128
116
// Position Select component's container above target/input
129
- // TODO: modify the yOffset instead & use one call to super.setStyle
130
117
selectFit . top = selectFit . targetRect . bottom + selectFit . styles . itemTextToInputTextDiff -
131
118
selectFit . contentElementRect . height ;
132
119
}
@@ -146,28 +133,25 @@ export class SelectPositioningStrategy extends BaseFitPositionStrategy implement
146
133
this . global_styles . contentElementNewWidth = selectFit . styles . contentElementNewWidth ;
147
134
}
148
135
149
- private calculateVariables ( selectFit : SelectFit ) {
150
- selectFit . itemRect = this . getInteractionItemElement ( ) . getBoundingClientRect ( ) ;
151
- selectFit . itemElement = this . getInteractionItemElement ( ) ;
152
- }
153
-
154
136
public calculateStyles ( selectFit : SelectFit ) : SelectStyles {
155
137
const styles : SelectStyles = { } ;
156
- const inputFontSize = window . getComputedStyle ( this . settings . target as Element ) . fontSize ;
138
+ const inputElementStyles = window . getComputedStyle ( this . settings . target as Element ) ;
139
+ const itemElementStyles = window . getComputedStyle ( selectFit . itemElement ) ;
140
+ const inputFontSize = inputElementStyles . fontSize ;
157
141
const numericInputFontSize = parseFloat ( inputFontSize ) ;
158
- const itemFontSize = window . getComputedStyle ( selectFit . itemElement ) . fontSize ;
142
+ const itemFontSize = itemElementStyles . fontSize ;
159
143
const numericItemFontSize = parseFloat ( itemFontSize ) ;
160
144
const inputTextToInputTop = ( selectFit . targetRect . bottom - selectFit . targetRect . top - numericInputFontSize ) / 2 ;
161
145
const itemTextToItemTop = ( selectFit . itemRect . height - numericItemFontSize ) / 2 ;
162
146
// Adjust for input top padding
163
147
const negateInputPaddings = (
164
- parseFloat ( window . getComputedStyle ( this . settings . target as Element ) . paddingTop ) -
165
- parseFloat ( window . getComputedStyle ( this . settings . target as Element ) . paddingBottom )
148
+ parseFloat ( inputElementStyles . paddingTop ) -
149
+ parseFloat ( inputElementStyles . paddingBottom )
166
150
) / 2 ;
167
151
styles . itemTextToInputTextDiff = Math . ceil ( itemTextToItemTop - inputTextToInputTop + negateInputPaddings ) ;
168
152
169
- const itemLeftPadding = window . getComputedStyle ( selectFit . itemElement ) . paddingLeft ;
170
- const itemTextIndent = window . getComputedStyle ( selectFit . itemElement ) . textIndent ;
153
+ const itemLeftPadding = itemElementStyles . paddingLeft ;
154
+ const itemTextIndent = itemElementStyles . textIndent ;
171
155
const numericLeftPadding = parseFloat ( itemLeftPadding ) ;
172
156
const numericTextIndent = parseFloat ( itemTextIndent ) ;
173
157
0 commit comments