Skip to content

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

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

Closed

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?

@pekingme pekingme requested a review from paulfthomas January 14, 2025 19:16
@paulfthomas paulfthomas added the Reviewing Internally An internal change has been created and sent for review. label Jan 15, 2025
@manabu-nakamura manabu-nakamura deleted the slider8 branch January 29, 2025 00:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Reviewing Internally An internal change has been created and sent for review.
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