@@ -184,27 +184,28 @@ export class ListLayout<T, O extends ListLayoutOptions = ListLayoutOptions> exte
184184 }
185185
186186 getVisibleLayoutInfos ( rect : Rect ) : LayoutInfo [ ] {
187- let visibleRect = rect . copy ( ) ;
188187 let offsetProperty = this . orientation === 'horizontal' ? 'x' : 'y' ;
189188 let heightProperty = this . orientation === 'horizontal' ? 'width' : 'height' ;
190189
191190 // Adjust rect to keep number of visible rows consistent.
192191 // (only if height > 1 or width > 1 for getDropTargetFromPoint)
193- if ( visibleRect [ heightProperty ] > 1 ) {
192+ if ( rect [ heightProperty ] > 1 ) {
194193 let rowHeight = ( this . rowSize ?? this . estimatedRowSize ?? DEFAULT_HEIGHT ) + this . gap ;
195- visibleRect [ offsetProperty ] = Math . floor ( visibleRect [ offsetProperty ] / rowHeight ) * rowHeight ;
196- visibleRect [ heightProperty ] = Math . ceil ( visibleRect [ heightProperty ] / rowHeight ) * rowHeight ;
194+ // Clone only before mutating
195+ rect = rect . copy ( ) ;
196+ rect [ offsetProperty ] = Math . floor ( rect [ offsetProperty ] / rowHeight ) * rowHeight ;
197+ rect [ heightProperty ] = Math . ceil ( rect [ heightProperty ] / rowHeight ) * rowHeight ;
197198 }
198199
199200 // If layout hasn't yet been done for the requested rect, union the
200201 // new rect with the existing valid rect, and recompute.
201- this . layoutIfNeeded ( visibleRect ) ;
202+ this . layoutIfNeeded ( rect ) ;
202203
203204 let res : LayoutInfo [ ] = [ ] ;
204205
205206 let addNodes = ( nodes : LayoutNode [ ] ) => {
206207 for ( let node of nodes ) {
207- if ( this . isVisible ( node , visibleRect ) ) {
208+ if ( this . isVisible ( node , rect ) ) {
208209 res . push ( node . layoutInfo ) ;
209210
210211 if ( node . children ) {
@@ -323,6 +324,9 @@ export class ListLayout<T, O extends ListLayoutOptions = ListLayoutOptions> exte
323324
324325 protected buildCollection ( offset : number = this . padding ) : LayoutNode [ ] {
325326 let collection = this . virtualizer ! . collection ;
327+ let offsetProperty = this . orientation === 'horizontal' ? 'x' : 'y' ;
328+ let maxOffsetProperty = this . orientation === 'horizontal' ? 'maxX' : 'maxY' ;
329+
326330 // filter out content nodes since we don't want them to affect the height
327331 // Tree specific for now, if we add content nodes to other collection items, we might need to reconsider this
328332 let collectionNodes = toArray ( collection , ( node ) => node . type !== 'content' ) ;
@@ -334,8 +338,6 @@ export class ListLayout<T, O extends ListLayoutOptions = ListLayoutOptions> exte
334338 }
335339
336340 for ( let node of collectionNodes ) {
337- let offsetProperty = this . orientation === 'horizontal' ? 'x' : 'y' ;
338- let maxOffsetProperty = this . orientation === 'horizontal' ? 'maxX' : 'maxY' ;
339341 let rowHeight = ( this . rowSize ?? this . estimatedRowSize ?? DEFAULT_HEIGHT ) + this . gap ;
340342 // Skip rows before the valid rectangle unless they are already cached.
341343 if ( node . type === 'item' && offset + rowHeight < this . requestedRect [ offsetProperty ] && ! this . isValid ( node , offset ) ) {
0 commit comments