This repository was archived by the owner on Nov 5, 2023. It is now read-only.
File tree 1 file changed +23
-5
lines changed
1 file changed +23
-5
lines changed Original file line number Diff line number Diff line change @@ -276,12 +276,30 @@ export function pipeline({
276
276
( [ scrollTo , { columns, itemHeightWithGap } , rootEl ] ) => {
277
277
const verticalScrollEl = getVerticalScrollParent ( rootEl ) ;
278
278
279
+ const computedStyle = window . getComputedStyle ( rootEl ) ;
280
+
281
+ const gridPaddingTop = parseInt (
282
+ computedStyle . getPropertyValue ( "padding-top" )
283
+ ) ;
284
+ const gridBoarderTop = parseInt (
285
+ computedStyle . getPropertyValue ( "border-top" )
286
+ ) ;
287
+
288
+ const topToGridContainer =
289
+ rootEl instanceof HTMLElement &&
290
+ verticalScrollEl instanceof HTMLElement
291
+ ? rootEl . offsetTop - verticalScrollEl . offsetTop
292
+ : 0 ;
293
+
294
+ // The offset within the scroll container
279
295
const scrollTop =
280
- // The offset within the grid container
281
- Math . floor ( ( scrollTo - 1 ) / columns ) * itemHeightWithGap +
282
- // Offset to the offsetParent
283
- ( rootEl instanceof HTMLElement ? rootEl . offsetTop : 0 ) ;
284
-
296
+ // row count * row height
297
+ Math . floor ( scrollTo / columns ) * itemHeightWithGap +
298
+ // top to the scroll container
299
+ topToGridContainer +
300
+ // the padding + boarder top of grid
301
+ gridPaddingTop +
302
+ gridBoarderTop ;
285
303
return [ verticalScrollEl , scrollTop ] ;
286
304
}
287
305
)
You can’t perform that action at this time.
0 commit comments