Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unsnap scrollable after snap_to operation #1795

Closed

Conversation

tarkah
Copy link
Member

@tarkah tarkah commented Apr 14, 2023

When issuing a snap_to operation to a scrollable, it leaves it's offset "relative".

This is typically fine, except for when you use on_scroll / snap_to to keep 2 separate scrollables in "sync". For example, consider a table widget that has a separate header scrollable from it's body scrollable. We can keep the header in sync w/ the body by firing snap_to on the header from the body's on_scroll message. If you have "resizing" functionality setup on the columns of the table and you are horizontally scrolled and try to "resize" a column, the two scrollables now behave in opposite ways.

  • The header which is at relative will stay x% scrolled as the width of the table changes, causing the viewport of the scrollable to change relative to the content.

  • The body which is at absolute will stay scrolled at x regardless of the width changing, keeping the viewport static.

The behavior of always having an absolute offset stored is desired for when content width changes.

This fixes the issue by always "unsnapping" after offset changes from an operation.

@tarkah
Copy link
Member Author

tarkah commented Apr 14, 2023

I just realized that snap_to is probably meant to keep things anchored at that percentage.

Maybe it'd be better to expose a scroll_to operation and have on_scroll transmit both the current relative and absolute offset to use for either?

@tarkah tarkah mentioned this pull request Apr 14, 2023
@tarkah
Copy link
Member Author

tarkah commented Apr 14, 2023

Closed in favor of #1796

@tarkah tarkah closed this Apr 14, 2023
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.

1 participant