xamarin / XamarinCommunityToolkit

The Xamarin Community Toolkit is a collection of Animations, Behaviors, Converters, and Effects for mobile development with Xamarin.Forms. It simplifies and demonstrates common developer tasks building iOS, Android, and UWP apps with Xamarin.Forms.
MIT License
1.58k stars 471 forks source link

[Bug] Toucheffect raised when scrolling #1261

Closed AlleSchonWeg closed 1 year ago

AlleSchonWeg commented 3 years ago

Description

The touch effect is raised, when the user only want to scroll the control with the attached effect. All infos about the issue are in the comments of the Pull Request. Starting at comment: https://github.com/xamarin/XamarinCommunityToolkit/pull/566#issuecomment-790958712

Expected Behavior

Touch effect should only raised it not scrolling, like ListView or CollectionView items.

Actual Behavior

Touch effect is raised on scrolling

Basic Information

Workaround

Reproduction imagery

Reproduction Link

AndreiMisiukevich commented 3 years ago

@AlleSchonWeg hi Is it on Android, right?

AlleSchonWeg commented 3 years ago

Hi @AndreiMisiukevich ,

i have only a Simulator for iOS, but it looks like the same problem with scrolling.

And some other thing happens. The item stays in "touched" mode. I created a video. The labels are greyed out sometimes:

https://user-images.githubusercontent.com/6727366/117143260-ed2e0e80-adb0-11eb-8ca3-6f27f6ef0ca2.mp4

IeuanWalker commented 3 years ago

@AndreiMisiukevich Might want to take a look at the platform implementation of this - https://github.com/IeuanWalker/Xamarin.Forms.StateButton

I'm not sure how the effects are implemented, but with this control 'Pressed' and 'Released' events are always raised (even when scrolling), but 'Clicked' event is only raised when the user clicks, but doest get raised when scrolling a list.

AndreiMisiukevich commented 3 years ago

If you know how to fix that, then feel free to submit PR

themronion commented 3 years ago

Yeap, +1 here, also noticed this recently

AlleSchonWeg commented 3 years ago

Hi @AndreiMisiukevich, on android i created a touch effect (ripple) which is only raised when the user selects an item. Not when scrolling. Perhaps you can use this and extend your touch effect:

         var label = new TextView(Context)
                    {
                        Text = $"Row ----- {i} in {noOfRows}",
                    };

                    label.Clickable = true;
                    label.Focusable = true;
                    int[] attrs = new int[] { Android.Resource.Attribute.SelectableItemBackground };
                    var typedArray = Context.ObtainStyledAttributes(attrs);
                    var drawableFromTheme = typedArray.GetDrawable(0);
                    typedArray.Recycle();
                    label.Foreground = drawableFromTheme;

In this example i used a label, which looks like this:

https://user-images.githubusercontent.com/6727366/119720276-100c8980-be6a-11eb-9316-f3e2fa4b7d29.mp4

RenegadeVile commented 3 years ago

This occurs with ScrollViews as well. Any View I add TouchEffect.NativeAnimation to will have that animation triggered when scrolling and I happen to start the scroll with a tap over said View.

Seuleuzeuh commented 3 years ago

Settings the xct:TouchEffect.DisallowTouchThreshold to 1 did the trick for me, using the NormalBackgroundColor and PressedBackgroundColor. And also with the LongPressCommand. All of that in elements of a CollectionView.

mphill commented 3 years ago

This may be related, but I want to make sure @AndreiMisiukevich is aware. With the IsToggle property, on iOS Scrolling (In a ScrollView) will randomly stop working with IsToggle is triggers. It like the control gets stuck into thinking it's pressed so scrolling stops.

I can reproduce this pretty reliably.

I switched to using a real Button that appears to have resolved my issue.

isness commented 3 years ago

I tried playing with this, but nothing works. Latest CF, Collection view. I'd really like to apply any kind of touch effect on a single line without having it triggered while scrolling :(

jfversluis commented 1 year ago

We believe this might be fixed in https://github.com/xamarin/XamarinCommunityToolkit/releases/tag/2.0.6

If not, please let uw know, open a new issue and link this one. Thanks!