Skip to content

Conversation

@seob717
Copy link
Contributor

@seob717 seob717 commented Nov 22, 2025

Added lane assignment caching to prevent items from jumping between lanes when viewport is resized. Previously, items could shift to different lanes during resize due to recalculating "shortest lane" with slightly different heights.

Changes:

  • Added laneAssignments cache (Map<index, lane>) to persist lane assignments
  • Lane cache is cleared when lanes option changes or measure() is called
  • Lane cache is cleaned up when count decreases (removes stale entries)
  • Lane cache is cleared when virtualizer is disabled

🤖 Generated with Claude Code

🎯 Changes

✅ Checklist

  • I have followed the steps listed in the Contributing guide.
  • I have tested and linted this code locally.
  • I have generated a changeset for this PR, or this PR should not release a new version.

@changeset-bot
Copy link

changeset-bot bot commented Nov 22, 2025

🦋 Changeset detected

Latest commit: 2ee9f57

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 7 packages
Name Type
@tanstack/virtual-core Patch
@tanstack/angular-virtual Patch
@tanstack/lit-virtual Patch
@tanstack/react-virtual Patch
@tanstack/solid-virtual Patch
@tanstack/svelte-virtual Patch
@tanstack/vue-virtual Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@seob717 seob717 force-pushed the fix/stable-masonry-lanes branch from 8f3e82f to 8fcdd95 Compare November 22, 2025 09:31
Added lane assignment caching to prevent items from jumping between lanes when viewport is resized. Previously, items could shift to different lanes during resize due to recalculating "shortest lane" with slightly different heights.

Changes:
- Added `laneAssignments` cache (Map<index, lane>) to persist lane assignments
- Lane cache is cleared when `lanes` option changes or `measure()` is called
- Lane cache is cleaned up when `count` decreases (removes stale entries)
- Lane cache is cleared when virtualizer is disabled
@seob717 seob717 force-pushed the fix/stable-masonry-lanes branch from 8fcdd95 to 8f360f5 Compare November 22, 2025 09:32
Use laneLastIndex array to track last item per lane instead of iterating through all measurements
@seob717 seob717 force-pushed the fix/stable-masonry-lanes branch from 7d61a38 to b6fc37a Compare November 22, 2025 10:51
@nx-cloud
Copy link

nx-cloud bot commented Nov 26, 2025

View your CI Pipeline Execution ↗ for commit 2ee9f57

Command Status Duration Result
nx affected --targets=test:sherif,test:knip,tes... ✅ Succeeded 2m 5s View ↗
nx run-many --target=build --exclude=examples/** ✅ Succeeded 15s View ↗

☁️ Nx Cloud last updated this comment at 2025-11-26 12:08:45 UTC

@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 26, 2025

More templates

@tanstack/angular-virtual

npm i https://pkg.pr.new/@tanstack/angular-virtual@1080

@tanstack/lit-virtual

npm i https://pkg.pr.new/@tanstack/lit-virtual@1080

@tanstack/react-virtual

npm i https://pkg.pr.new/@tanstack/react-virtual@1080

@tanstack/solid-virtual

npm i https://pkg.pr.new/@tanstack/solid-virtual@1080

@tanstack/svelte-virtual

npm i https://pkg.pr.new/@tanstack/svelte-virtual@1080

@tanstack/virtual-core

npm i https://pkg.pr.new/@tanstack/virtual-core@1080

@tanstack/vue-virtual

npm i https://pkg.pr.new/@tanstack/vue-virtual@1080

commit: 2ee9f57

@piecyk
Copy link
Collaborator

piecyk commented Nov 26, 2025

@seob717 Looks great overall, the lane caching + settling logic makes the masonry layout much more stable on resize.

@piecyk piecyk merged commit 96e32a6 into TanStack:main Nov 26, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants