@@ -33,7 +33,7 @@ export abstract class BaseScrollStrategy {
3333 abstract getTotalContentSize ( virtualItems : VirtualItem [ ] ) : Size ;
3434 protected abstract getScrollOffset ( viewport : ViewportMetrics ) : number ;
3535 protected abstract getClientSize ( viewport : ViewportMetrics ) : number ;
36-
36+
3737 /**
3838 * Returns the item's extent along the scroll axis. Vertical layout uses height;
3939 * horizontal layout uses width. Used for visible range and end spacing calculations.
@@ -50,6 +50,15 @@ export abstract class BaseScrollStrategy {
5050 return ( totalContentSize . width - _item . width ) / 2 ;
5151 }
5252
53+ /**
54+ * Vertical centering offset for items shorter than the content max height.
55+ * Horizontal layout centers items within the row height; vertical layout keeps
56+ * items top-aligned and uses the default of 0.
57+ */
58+ protected getCenteringOffsetY ( _item : VirtualItem , _totalContentSize : Size | undefined ) : number {
59+ return 0 ;
60+ }
61+
5362 protected getVisibleRange (
5463 viewport : ViewportMetrics ,
5564 virtualItems : VirtualItem [ ] ,
@@ -133,10 +142,11 @@ export abstract class BaseScrollStrategy {
133142
134143 virtualItems . forEach ( ( item ) => {
135144 const centeringOffsetX = this . getCenteringOffsetX ( item , totalContentSize ) ;
145+ const centeringOffsetY = this . getCenteringOffsetY ( item , totalContentSize ) ;
136146
137147 item . pageLayouts . forEach ( ( page ) => {
138148 const itemX = ( item . x + centeringOffsetX ) * scale ;
139- const itemY = item . y * scale ;
149+ const itemY = ( item . y + centeringOffsetY ) * scale ;
140150 const pageX = itemX + page . x * scale ;
141151 const pageY = itemY + page . y * scale ;
142152 const pageWidth = page . rotatedWidth * scale ;
@@ -212,11 +222,12 @@ export abstract class BaseScrollStrategy {
212222 if ( ! pageLayout ) return null ;
213223
214224 const centeringOffsetX = this . getCenteringOffsetX ( item , totalContentSize ) ;
225+ const centeringOffsetY = this . getCenteringOffsetY ( item , totalContentSize ) ;
215226
216227 return {
217228 origin : {
218229 x : item . x + pageLayout . x + centeringOffsetX ,
219- y : item . y + pageLayout . y ,
230+ y : item . y + pageLayout . y + centeringOffsetY ,
220231 } ,
221232 size : {
222233 width : pageLayout . width ,
0 commit comments