@@ -141,116 +141,137 @@ export class PositionEngine {
141141
142142 let parent = this . options . element . offsetParent ;
143143
144- let offsetTop = 0 ;
145- let offsetLeft = 0 ;
146- let scrollOffset = 0 ;
144+ let accOffsetTop = 0 ;
145+ let accOffsetLeft = 0 ;
146+ let accScrollTop = scrollTop ;
147+ let accScrollLeft = scrollLeft ;
147148
148149 /* eslint-disable no-console -- still in development */
149150
150151 console . clear ( ) ;
151152
153+ console . group ( "Measure parent offset" ) ;
154+
152155 while ( parent ) {
153156 if ( parent instanceof HTMLElement ) {
154- offsetTop += parent . offsetTop ;
155- offsetLeft += parent . offsetLeft ;
156- scrollOffset += parent . scrollHeight - parent . offsetHeight ;
157-
158- console . log ( "offsetParent" , parent ) ;
157+ accOffsetTop += parent . offsetTop ;
158+ accOffsetLeft += parent . offsetLeft ;
159+ accScrollTop += parent . scrollTop ;
160+ accScrollLeft += parent . scrollLeft ;
161+
162+ console . group ( "offsetParent" , parent ) ;
163+ console . log ( "position" , window . getComputedStyle ( parent ) . position ) ;
164+ console . log ( "marginTop" , window . getComputedStyle ( parent ) . marginTop ) ;
165+ console . log ( "paddingTop" , window . getComputedStyle ( parent ) . paddingTop ) ;
166+ console . log ( "offsetTop" , parent . offsetTop ) ;
159167 console . log ( "offsetLeft" , parent . offsetLeft ) ;
160- console . log (
161- "top / height / scrollHeight / scrollTop" ,
162- parent . offsetTop ,
163- parent . offsetHeight ,
164- parent . scrollHeight ,
165- parent . scrollTop ,
166- ) ;
168+ console . log ( "offsetHeight" , parent . offsetHeight ) ;
169+ console . log ( "offsetWidth" , parent . offsetWidth ) ;
170+ console . log ( "clientHeight" , parent . clientHeight ) ;
171+ console . log ( "clientWidth" , parent . clientWidth ) ;
172+ console . log ( "scrollHeight" , parent . scrollHeight ) ;
173+ console . log ( "scrollTop" , parent . scrollTop ) ;
174+ console . log ( "scrollLengthTop" , parent . scrollHeight - parent . offsetHeight ) ;
175+ console . log ( "scrollWidth" , parent . scrollWidth ) ;
176+ console . log ( "scrollLeft" , parent . scrollLeft ) ;
177+ console . log ( "scrollLengthLeft" , parent . scrollWidth - parent . offsetWidth ) ;
178+ console . log ( "rect" , parent . getBoundingClientRect ( ) ) ;
179+ console . groupEnd ( ) ;
167180 }
168181
169182 parent = parent instanceof HTMLElement ? parent . offsetParent : null ;
170183 }
184+ console . groupEnd ( ) ;
185+
186+ console . group ( "Acc ---------------------" ) ;
187+ console . log ( "accOffsetLeft" , accOffsetLeft ) ;
188+ console . log ( "accOffsetTop" , accOffsetTop ) ;
189+ console . log ( "accScrollLeft" , accScrollLeft ) ;
190+ console . log ( "accScrollTop" , accScrollTop ) ;
191+ console . groupEnd ( ) ;
171192
172- console . log ( "total offsetLeft" , offsetLeft ) ;
173- console . log ( "total offsetTop" , offsetTop ) ;
174- console . log ( "height" , availableSpace [ "top-start" ] . y ) ;
193+ console . group ( "Render ------------------" ) ;
194+ console . log ( "availableSpace" , availableSpace ) ;
175195 console . log ( "rect.top" , rect . top ) ;
176196 console . log ( "rect.bottom" , rect . bottom ) ;
177197 console . log ( "rect.height" , rect . height ) ;
178198 console . log ( "windowHeight" , windowHeight ) ;
199+ console . log ( "windowWidth" , windowWidth ) ;
179200 console . log ( "scrollTop" , scrollTop ) ;
180- console . log ( "scrollOffset" , scrollOffset ) ;
201+ console . groupEnd ( ) ;
181202
182203 /* eslint-enable no-console */
183204
184205 return {
185206 "top-start" : {
186- bottom : `${ windowHeight - rect . top - scrollTop } px` ,
187- left : `${ scrollLeft + rect . left } px` ,
207+ bottom : `${ windowHeight - rect . top - accScrollTop } px` ,
208+ left : `${ accScrollLeft + rect . left } px` ,
188209 maxWidth : `${ availableSpace [ "top-start" ] . x } px` ,
189210 maxHeight : `${ availableSpace [ "top-start" ] . y } px` ,
190211 } ,
191212 "top-center" : {
192- bottom : `${ windowHeight - rect . top - scrollTop } px` ,
193- left : `${ scrollLeft + rect . left } px` ,
213+ bottom : `${ windowHeight - rect . top - accScrollTop } px` ,
214+ left : `${ accScrollLeft + rect . left - accOffsetLeft } px` ,
194215 width : `${ availableSpace [ "top-center" ] . x } px` ,
195216 maxHeight : `${ availableSpace [ "top-center" ] . y } px` ,
196217 } ,
197218 "top-end" : {
198- bottom : `${ windowHeight - rect . top - scrollTop } px` ,
199- right : `${ windowWidth - rect . right - scrollLeft } px` ,
219+ bottom : `${ windowHeight - rect . top - accScrollTop } px` ,
220+ right : `${ windowWidth - rect . right - accScrollLeft } px` ,
200221 maxWidth : `${ availableSpace [ "top-end" ] . x } px` ,
201222 maxHeight : `${ availableSpace [ "top-end" ] . y } px` ,
202223 } ,
203224 "right-start" : {
204- top : `${ rect . top + scrollTop - offsetTop } px` ,
205- left : `${ scrollLeft + rect . right - offsetLeft } px` ,
225+ top : `${ rect . top + accScrollTop - accOffsetTop } px` ,
226+ left : `${ accScrollLeft + rect . right - accOffsetLeft } px` ,
206227 maxWidth : `${ availableSpace [ "right-start" ] . x } px` ,
207228 maxHeight : `${ availableSpace [ "right-start" ] . y } px` ,
208229 } ,
209230 "right-center" : {
210- top : `${ rect . top + scrollTop - offsetTop } px` ,
211- left : `${ scrollLeft + rect . right - offsetLeft } px` ,
231+ top : `${ rect . top + accScrollTop - accOffsetTop } px` ,
232+ left : `${ accScrollLeft + rect . right - accOffsetLeft } px` ,
212233 maxWidth : `${ availableSpace [ "right-center" ] . x } px` ,
213234 height : `${ availableSpace [ "right-center" ] . y } px` ,
214235 } ,
215236 "right-end" : {
216- bottom : `${ windowHeight - rect . bottom - scrollTop } px` ,
217- left : `${ scrollLeft + rect . right - offsetLeft } px` ,
237+ bottom : `${ windowHeight - rect . bottom - accScrollTop + accOffsetTop } px` ,
238+ left : `${ accScrollLeft + rect . right - accOffsetLeft } px` ,
218239 maxWidth : `${ availableSpace [ "right-end" ] . x } px` ,
219240 maxHeight : `${ availableSpace [ "right-end" ] . y } px` ,
220241 } ,
221242 "bottom-start" : {
222- top : `${ scrollTop + rect . bottom - offsetTop } px` ,
223- left : `${ scrollLeft + rect . left - offsetLeft } px` ,
243+ top : `${ accScrollTop + rect . bottom - accOffsetTop } px` ,
244+ left : `${ accScrollLeft + rect . left - accOffsetLeft } px` ,
224245 maxWidth : `${ availableSpace [ "bottom-start" ] . x } px` ,
225246 maxHeight : `${ availableSpace [ "bottom-start" ] . y } px` ,
226247 } ,
227248 "bottom-center" : {
228- top : `${ scrollTop + rect . bottom - offsetTop } px` ,
229- left : `${ scrollLeft + rect . left - offsetLeft } px` ,
249+ top : `${ accScrollTop + rect . bottom - accOffsetTop } px` ,
250+ left : `${ accScrollLeft + rect . left - accOffsetLeft } px` ,
230251 width : `${ availableSpace [ "bottom-center" ] . x } px` ,
231252 maxHeight : `${ availableSpace [ "bottom-center" ] . y } px` ,
232253 } ,
233254 "bottom-end" : {
234- top : `${ scrollTop + rect . bottom - offsetTop } px` ,
235- right : `${ windowWidth - rect . right - offsetLeft } px` ,
255+ top : `${ accScrollTop + rect . bottom - accOffsetTop } px` ,
256+ right : `${ windowWidth - rect . right - accOffsetLeft - accScrollLeft } px` ,
236257 maxWidth : `${ availableSpace [ "bottom-end" ] . x } px` ,
237258 maxHeight : `${ availableSpace [ "bottom-end" ] . y } px` ,
238259 } ,
239260 "left-start" : {
240- top : `${ rect . top + scrollTop - offsetTop } px` ,
241- right : `${ windowWidth - scrollLeft - rect . left - offsetLeft } px` ,
261+ top : `${ rect . top + accScrollTop - accOffsetTop } px` ,
262+ right : `${ windowWidth - rect . left - accOffsetLeft - accScrollLeft } px` ,
242263 maxWidth : `${ availableSpace [ "left-start" ] . x } px` ,
243264 maxHeight : `${ availableSpace [ "left-start" ] . y } px` ,
244265 } ,
245266 "left-center" : {
246- top : `${ rect . top + scrollTop - offsetTop } px` ,
247- right : `${ windowWidth - scrollLeft - rect . left - offsetLeft } px` ,
267+ top : `${ rect . top + accScrollTop - accOffsetTop } px` ,
268+ right : `${ windowWidth - rect . left - accOffsetLeft - accScrollLeft } px` ,
248269 maxWidth : `${ availableSpace [ "left-center" ] . x } px` ,
249270 height : `${ availableSpace [ "left-center" ] . y } px` ,
250271 } ,
251272 "left-end" : {
252- bottom : `${ windowHeight - rect . bottom - scrollTop } px` ,
253- right : `${ windowWidth - scrollLeft - rect . left - offsetLeft } px` ,
273+ bottom : `${ windowHeight - rect . bottom - accScrollTop + accOffsetTop } px` ,
274+ right : `${ windowWidth - rect . left - accOffsetLeft - accScrollLeft } px` ,
254275 maxWidth : `${ availableSpace [ "left-end" ] . x } px` ,
255276 maxHeight : `${ availableSpace [ "left-end" ] . y } px` ,
256277 } ,
0 commit comments