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

[Slider] Fixed behaviour when Slider is in a scrolling container #4511

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

Conversation

manabu-nakamura
Copy link
Contributor

closes #4510

@drchen drchen requested a review from paulfthomas January 2, 2025 18:14
@@ -43,10 +44,11 @@ public View onCreateDemoView(
for (int i = 0; i < 50; i++) {
Slider slider = new Slider(layoutInflater.getContext());
slider.setValueTo(11f);
slider.setOrientation(SliderOrientation.VERTICAL);
Copy link
Member

Choose a reason for hiding this comment

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

Could you create a separate demo for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I created it.

@@ -2864,17 +2865,24 @@ public boolean onTouchEvent(@NonNull MotionEvent event) {
}

float eventCoordinate = isVertical() ? event.getY() : event.getX();
Copy link
Member

Choose a reason for hiding this comment

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

Rename this to eventCoordinateX

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I renamed it.

&& abs(eventCoordinate - touchDownX) < scaledTouchSlop) {
return false;
}
// Check if we're trying to scroll horizontally instead of dragging this Slider
if (isVertical() && isPotentialHorizontalScroll(event)
&& abs(eventCoordinateY - touchDownY) < scaledTouchSlop / 1.2) {
Copy link
Member

Choose a reason for hiding this comment

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

Can you explain this 1.2?

Copy link
Contributor Author

@manabu-nakamura manabu-nakamura Jan 7, 2025

Choose a reason for hiding this comment

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

It is difficult for me to explain it...
If scaledTouchSlop is not divided by 1.2, it is difficult to slide (drag) vertical sliders. Try it.

Copy link
Member

Choose a reason for hiding this comment

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

Is this also applicable for the vertical scroll or is it specific to this horizontal scroll?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems to be specific to horizontal scroll. Don't you think so?

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.

[Slider] vertical slider in horizontal scrollview can not be scrolled
2 participants