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

Fix scroll_with_delta only scrolling if the ScrollArea is focussed #4303

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

lucasmerlin
Copy link
Contributor

This introduces the boolean field force_current_scroll_area to InputState which will be set when scroll_with_delta is called, causing the ScrollArea to skip the check whether it is focused and always consume the smooth scroll delta.

Comment on lines 1095 to 1096
input.smooth_scroll_delta += delta;
input.force_current_scroll_area = true;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a better fix is to add a scroll_delta to FrameState, alongside FrameState::scroll_target

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is indeed much nicer 👍 I've updated my PR

pub(crate) scroll_target: [Option<(Rangef, Option<Align>)>; 2],

/// The current scroll area should scroll by this much (horizontal, vertical).
pub(crate) scroll_delta: [Option<f32>; 2],
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could just be a Vec2, no?

Suggested change
pub(crate) scroll_delta: [Option<f32>; 2],
pub(crate) scroll_delta: Vec2,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated. I think we could also update scroll_target to be Option<[(..); 2]> instead of [Option<(..)>; 2]. That would make the code in Prepared::end a bit cleaner. I don't think a single direction is ever read / set alone, it's always both directions at once. Should I include that change as well?

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.

scroll_with_delta doesn't work
2 participants