dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.25k stars 1.76k forks source link

UIScrollView able to pan past content inside scrollview when zooming (iOS) #23163

Open Cast324 opened 5 months ago

Cast324 commented 5 months ago

Description

When you enable zooming in a iOS UIScrollView you are able to pan past the content bounds. This was not the case in Xamarin.

https://github.com/dotnet/maui/assets/6510334/d089bb81-bdc3-42db-8a02-846094a87d0a

I also have a test in Xamarin for you to compare. You can see that in xamarin the content inside the scrollview is scaled up to the scrollview size despite having a width and height request this is not the case in MAUI.

https://github.com/Cast324/ScrollViewTestXamarin

Steps to Reproduce

Create a ScrollViewHandler for iOS like the following:

#if IOS
        Microsoft.Maui.Handlers.ScrollViewHandler.Mapper.AppendToMapping(nameof(CustomScrollView), (handler, view) =>
        {
            handler.PlatformView.MinimumZoomScale = 1;
            handler.PlatformView.MaximumZoomScale = 5;
            handler.PlatformView.ViewForZoomingInScrollView += (UIKit.UIScrollView sv) =>
            {
                return handler.PlatformView.Subviews[0];
            };
        });
#endif

Then add it to the view like the following:

<ContentPage x:Class="ScrollViewTestXamarin.MainPage"
             xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:items="clr-namespace:ScrollViewTestXamarin">

    <items:CustomScrollView HorizontalScrollBarVisibility="Always" VerticalScrollBarVisibility="Always">
        <ContentView BackgroundColor="Red"
                     HeightRequest="200"
                     WidthRequest="200" />
    </items:CustomScrollView>

</ContentPage>

Link to public reproduction project repository

https://github.com/Cast324/ScrollViewTestRepo

Version with bug

8.0.60 SR6

Is this a regression from previous behavior?

Yes, this used to work in Xamarin.Forms

Last version that worked well

Unknown/Other

Affected platforms

iOS

Affected platform versions

iOS 17

Did you find any workaround?

No workaround known currently.

Relevant log output

No response

github-actions[bot] commented 5 months ago

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.

kevinxufei commented 5 months ago

Verified this issue with Visual Studio 17.11.0 Preview 2.1 (8.0.60 & 8.0.40). Can repro on iOS platform with sample project. And it works fine on Xamarin.Forms

ardentra commented 4 months ago

+1 we are stuck here

reid-kirkpatrick commented 4 months ago

this is a big blocker for our conversion

Uridel commented 4 months ago

Currently experiencing the same issue with my own project. Has anyone managed to find a workaround?