AndreiMisiukevich / TouchEffect

UI-responsive touch effects for Xamarin.Forms

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Element occasionally doesnt return to regular state if nested in ScrollView, state "regular" is not fired

lltwist opened this issue · comments

I'm using TouchEff for items in Bindable StackLayout and having a problem with items get stuck in "pressed" state if some scroll of ScrollView occured concurrently with pressing of item. Is there any workarounds to solve this? If item is just tapped - everything works ok.

<RefreshView Grid.Row="4"
                                 Margin="0,10,0,0"
                                 IsRefreshing="{Binding Path=IsRefreshing}"
                                 Command="{Binding Path=RefreshCommand}">
                        <ScrollView
                            x:Name="BottomSheetScrollView"
                            Orientation="Vertical"
                            VerticalScrollBarVisibility="Never"
                            HorizontalScrollBarVisibility="Never"
                            Scrolled="BottomSheetScrollView_OnScrolled">
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="*" />
                                    <RowDefinition Height="24" />
                                </Grid.RowDefinitions>
                                <StackLayout
                                    x:Name="BottomSheetListView"
                                    Style="{StaticResource StackLayoutListViewStyle}"
                                    BindableLayout.ItemsSource="{Binding Path=Packs}"
                                    BindableLayout.ItemTemplateSelector="{...}">
                                </StackLayout>
                            </Grid>
                       </ScrollView>
</RefreshView>

...

// ITEM TEMPLATE:

<Frame
        x:Name="PackItemFrame"
        Style="{StaticResource PackItemFrameStyle}"
        BackgroundColor="{StaticResource PacksFrontWhiteColor}"
        BorderColor="{StaticResource PacksFrontLightBlueColor}"
        touchEffect:TouchEff.Command="{Binding Path=ItemTappedCommand}"
        touchEffect:TouchEff.PressedOpacity="0.75"
        touchEffect:TouchEff.PressedAnimationDuration="250"
        touchEffect:TouchEff.PressedScale="0.98">
        <Frame.Effects>
            <touchEffect:TouchEff  />
        </Frame.Effects>
...
</Frame>

...

right now i handle with it like this:

 private async void BottomSheetScrollView_OnScrolled(System.Object sender, Xamarin.Forms.ScrolledEventArgs e)
        {
            Device.BeginInvokeOnMainThread(() =>
                BottomSheetListView.Children.ForEach(c =>
                {
                    var ef = c.Effects.FirstOrDefault(effect => effect is TouchEff) as TouchEff;

                    if (!ef.IsDefault())
                        ef.HandleTouch(TouchStatus.Canceled);
                }));

            if (_isTransitioning)
                await BottomSheetScrollView.ScrollToAsync(0d, _previousScroll, false);
            else
            {
                _previousScroll = e.ScrollY;
            }

        }

DisallowTouchThreshold = 10 for Android

Can you test the same case on iOS with latest nuget version?

#46 the same

Set Target Framework to Android 9.0 (API 28 at least)
Also, use the latest stable xamarin forms (4.5 or newer)