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

Scrollview doesn't recognize scroll command after any gesture recognizer implemented #22666

Open
tataelm opened this issue May 27, 2024 · 4 comments
Labels
area-controls-scrollview ScrollView platform/android 🤖 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Milestone

Comments

@tataelm
Copy link

tataelm commented May 27, 2024

Description

            <ScrollView x:Name="scrollView">
                <StackLayout
                    x:Name="stackpanel_preview_vertical"
                    Grid.Column="0"
                    Margin="15"
                    Orientation="Vertical"
                    Scale="1">
                    <StackLayout.GestureRecognizers>
                        <PinchGestureRecognizer PinchUpdated="StackLayout_Zoom_OnPinchUpdated" />
                    </StackLayout.GestureRecognizers>
                </StackLayout>
            </ScrollView>

If any gesture recognizer is implemented to ScrollView or any child element under ScrollView, scrolling stops working. Scrolling is essentially a "pan gesture", yet implementing other gestures will make it stop too.

I also tested it like this, outcome is the same.

            <ScrollView x:Name="scrollView">
                <ScrollView.GestureRecognizers>
                    <PinchGestureRecognizer PinchUpdated="StackLayout_Zoom_OnPinchUpdated" />
                </ScrollView.GestureRecognizers>

                <StackLayout
                    x:Name="stackpanel_preview_vertical"
                    Grid.Column="0"
                    Margin="15"
                    Orientation="Vertical"
                    Scale="1" />
            </ScrollView>

Steps to Reproduce

No response

Link to public reproduction project repository

No response

Version with bug

9.0.0-preview.3.10457

Is this a regression from previous behavior?

No, this is something new, Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

No response

Did you find any workaround?

As a workaround I implemented my own scroll event by adding "PanGestureRecognizer", yet the native scroll behaviours would be better.

            <ScrollView x:Name="scrollView">
                <ScrollView.GestureRecognizers>
                    <PinchGestureRecognizer PinchUpdated="StackLayout_Zoom_OnPinchUpdated" />
                    <PanGestureRecognizer PanUpdated="PanGestureRecognizer_PanUpdated" />
                </ScrollView.GestureRecognizers>

                <StackLayout
                    x:Name="stackpanel_preview_vertical"
                    Grid.Column="0"
                    Margin="15"
                    Orientation="Vertical"
                    Scale="1" />
            </ScrollView>


private void PanGestureRecognizer_PanUpdated(object sender, PanUpdatedEventArgs e)
{      
    switch (e.StatusType)
    {
        case GestureStatus.Started:
            // do something with it.
            break;

        case GestureStatus.Running:

            double translateY = e.TotalY;
            var maxScrollOffset = (stackpanel_preview_vertical.Height * _currentScale) - this.Height;

            var absoluteYOffsetLocation = Math.Abs(_yOffsetLocation);
            var positiveTranslateY = Math.Abs(translateY);

            if (translateY < 0) // scrolling down
            {
                var calculatedTranslationY = absoluteYOffsetLocation + positiveTranslateY;
                if (calculatedTranslationY > maxScrollOffset)
                    stackpanel_preview_vertical.TranslationY = maxScrollOffset * -1;
                else
                    stackpanel_preview_vertical.TranslationY = _yOffsetLocation + translateY;
            }
            else if (translateY > 0)// scrolling up
            {
                var calculatedTranslationY = absoluteYOffsetLocation - positiveTranslateY;
                if (calculatedTranslationY <= 0)
                    stackpanel_preview_vertical.TranslationY = 0;
                else
                    stackpanel_preview_vertical.TranslationY = _yOffsetLocation + translateY;

            }
            else
            {
                if (absoluteYOffsetLocation < 0)
                    stackpanel_preview_vertical.TranslationY = 0;
                else if (absoluteYOffsetLocation > maxScrollOffset)
                    stackpanel_preview_vertical.TranslationY = maxScrollOffset * -1;
            }

            break;


        case GestureStatus.Completed:
            _yOffsetLocation = stackpanel_preview_vertical.TranslationY;
            break;
    }
}

Relevant log output

No response

@tataelm tataelm added the t/bug Something isn't working label May 27, 2024
Copy link
Contributor

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

@mattleibow
Copy link
Member

Duplicate of #10213

@mattleibow mattleibow marked this as a duplicate of #10213 May 27, 2024
@Eilon Eilon added the area-controls-scrollview ScrollView label May 28, 2024
@RoiChen001 RoiChen001 added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels May 29, 2024
@RoiChen001
Copy link

Can repro this issue at Android platform on the latest 17.11.0 Preview 1.0(8.0.40/9.0.0-preview.2.10293/9.0.0-preview.3.10457).

@jsuarezruiz jsuarezruiz added this to the Backlog milestone Jun 4, 2024
@samhouts samhouts removed s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Jul 3, 2024
@samhouts samhouts added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Jul 10, 2024
@tataelm
Copy link
Author

tataelm commented Sep 14, 2024

still no improvement on this? The issue #10213 opened in 2022

Duplicate of #10213

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-controls-scrollview ScrollView platform/android 🤖 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants