@@ -94,22 +94,6 @@ export class Positioning {
94
94
? this . offset ( hostElement , false )
95
95
: this . position ( hostElement , false ) ;
96
96
const targetElStyles = this . getAllStyles ( targetElement ) ;
97
- const shiftWidth : any = {
98
- left : hostElPosition . left ,
99
- center :
100
- hostElPosition . left +
101
- hostElPosition . width / 2 -
102
- targetElement . offsetWidth / 2 ,
103
- right : hostElPosition . left + hostElPosition . width
104
- } ;
105
- const shiftHeight : any = {
106
- top : hostElPosition . top ,
107
- center :
108
- hostElPosition . top +
109
- hostElPosition . height / 2 -
110
- targetElement . offsetHeight / 2 ,
111
- bottom : hostElPosition . top + hostElPosition . height
112
- } ;
113
97
const targetElBCR = targetElement . getBoundingClientRect ( ) ;
114
98
let placementPrimary = placement . split ( ' ' ) [ 0 ] || 'top' ;
115
99
const placementSecondary = placement . split ( ' ' ) [ 1 ] || 'center' ;
@@ -123,6 +107,23 @@ export class Positioning {
123
107
right : targetElBCR . width || targetElement . offsetWidth
124
108
} ;
125
109
110
+ const shiftHeight : any = {
111
+ top : hostElPosition . top ,
112
+ center :
113
+ hostElPosition . top +
114
+ hostElPosition . height / 2 -
115
+ targetElPosition . height / 2 ,
116
+ bottom : hostElPosition . top + hostElPosition . height
117
+ } ;
118
+ const shiftWidth : any = {
119
+ left : hostElPosition . left ,
120
+ center :
121
+ hostElPosition . left +
122
+ hostElPosition . width / 2 -
123
+ targetElPosition . width / 2 ,
124
+ right : hostElPosition . left + hostElPosition . width
125
+ } ;
126
+
126
127
if ( placementPrimary === 'auto' ) {
127
128
let newPlacementPrimary = this . autoPosition (
128
129
targetElPosition ,
@@ -144,10 +145,10 @@ export class Positioning {
144
145
case 'top' :
145
146
targetElPosition . top =
146
147
hostElPosition . top -
147
- ( targetElement . offsetHeight +
148
+ ( targetElPosition . height +
148
149
parseFloat ( targetElStyles . marginBottom ) ) ;
149
150
targetElPosition . bottom +=
150
- hostElPosition . top - targetElement . offsetHeight ;
151
+ hostElPosition . top - targetElPosition . height ;
151
152
targetElPosition . left = shiftWidth [ placementSecondary ] ;
152
153
targetElPosition . right += shiftWidth [ placementSecondary ] ;
153
154
break ;
@@ -162,9 +163,9 @@ export class Positioning {
162
163
targetElPosition . bottom += shiftHeight [ placementSecondary ] ;
163
164
targetElPosition . left =
164
165
hostElPosition . left -
165
- ( targetElement . offsetWidth + parseFloat ( targetElStyles . marginRight ) ) ;
166
+ ( targetElPosition . width + parseFloat ( targetElStyles . marginRight ) ) ;
166
167
targetElPosition . right +=
167
- hostElPosition . left - targetElement . offsetWidth ;
168
+ hostElPosition . left - targetElPosition . width ;
168
169
break ;
169
170
case 'right' :
170
171
targetElPosition . top = shiftHeight [ placementSecondary ] ;
@@ -190,28 +191,28 @@ export class Positioning {
190
191
) {
191
192
if (
192
193
( ! preferredPosition || preferredPosition === 'right' ) &&
193
- targetElPosition . left + hostElPosition . left - targetElement . offsetWidth <
194
+ targetElPosition . left + hostElPosition . left - targetElPosition . width <
194
195
0
195
196
) {
196
197
return 'right' ;
197
198
} else if (
198
199
( ! preferredPosition || preferredPosition === 'top' ) &&
199
200
targetElPosition . bottom +
200
201
hostElPosition . bottom +
201
- targetElement . offsetHeight >
202
+ targetElPosition . height >
202
203
window . innerHeight
203
204
) {
204
205
return 'top' ;
205
206
} else if (
206
207
( ! preferredPosition || preferredPosition === 'bottom' ) &&
207
- targetElPosition . top + hostElPosition . top - targetElement . offsetHeight < 0
208
+ targetElPosition . top + hostElPosition . top - targetElPosition . height < 0
208
209
) {
209
210
return 'bottom' ;
210
211
} else if (
211
212
( ! preferredPosition || preferredPosition === 'left' ) &&
212
213
targetElPosition . right +
213
214
hostElPosition . right +
214
- targetElement . offsetWidth >
215
+ targetElPosition . width >
215
216
window . innerWidth
216
217
) {
217
218
return 'left' ;
0 commit comments