AvaloniaUI / Avalonia

Develop Desktop, Embedded, Mobile and WebAssembly apps with C# and XAML. The most popular .NET UI client technology
https://avaloniaui.net
MIT License
25.41k stars 2.2k forks source link

[Touch Only Bug] Transition of the Carousel is started for no reason #12176

Open dbriard opened 1 year ago

dbriard commented 1 year ago

EDIT: ignore this message, see my next comment below for the issue cause.

I have a view with a Carousel containing two pages:

Page 1) A view with a search buttons Page 2) A view containing the search results in a ItemsRepeater inside a ScrollViewer, with a Title and few filter options in a sticky header. image

When the user click Enter in the SearchBox, I add a second item to the carousel with an ItemRepeater for the results.

The results are an incremental collection of photos. When the vertical offset of the ScrollViewer is hit, I load in the ItemsSource of ItemsRepeater (ObservableCollection).

With the Mouse, I can scroll down as much as I want with no problem. With the finger, however, I can scroll but when the new items are added to the ItemsRepeater, the view disapear! including the results, the title and the filters. But I still can click on the items.

I checked with the Inspector: The Carousel SelectedIndex is still 1. (my second page with search results page) However a new ContentPresenter has been added into the Carousel panel image

And the previous ContentPresenter containing my page, now has its Opacity set to 0! image

I cannot produce a Repro at the moment. I tested on pc with a touch screen, WASM or Desktop, on a android phone, and in a android sumulator.

Avalonia v11.0

No problem with mouse.

I have no idea what happen at the moment, the issue could be in the Carousel may be. I will continue to try to create a minimum repro.

dbriard commented 1 year ago

I think I found something.

I have a transition on the Carousel, and I registered the TransitionStarted and TransitionCompleted event. When I scroll with finger to the end of my vertical search result page, TransitionStarted on the surrounding Carousel is called.. which should not happend (my Carousel is horizontal).

The disapearing page is due do an Opacity change in my custom transition, but the bug is that the transition should not happen in the first place.

dbriard commented 1 year ago

I created a repro sample for this issue CarouselBugWithFinger.zip

Steps:

  1. Type anything in the SearchBox, the carousel slide to the 2nd page
  2. On the second page, scroll with mouse => see everything is ok
  3. Try to scroll with finger => the view disapear when scrollview hit top (try to scrollup when at 0) or bottom... (a college also reproduce with two fingers on its trackpage, but I cannot on mine, only touch screen).

Alternate tests: In Views/UnsplashView.axaml.cs, comment the line : carousel.PageTransition = pageSlide; to remove the transition. Now, instead of making the view disapear, the view is recreated each time the scroll with finger hit negative position or bottom. I can see that in ItemsRepeaterEx.cs, those methods are called with finger image

Another test: Replacing Carousel with TransitioningContentControl (commented in UnsplashView.axaml) There is no more issue with scrolling using the finger.

May be I could use TransitioningContentControl instead of Carousel, but I also need backward transition, and I think TransitioningContentControl's old content is remove at the begining of the transition.

@timunie Could you have a look at my sample to see if it is a bug in Carousel ??? I cannot understand the behavior at all...

Thanks a lot!

timunie commented 1 year ago

I can't as I have no touch device for debugging. Sorry. Haven't checked your sample, is it v11.0? If so, please try latest nightly as things already may have changed.

dbriard commented 1 year ago

Hi @timunie Yes it is 11.0.0 but I have had this bug since I started to work with Avalonia (preview 4). Until now, I belived it was an Android bug, when I was trying my app on my Android phone's browser. But know that I have a touch screen I know that it is related to touch device instead.

Do you know someone in Avalonia's team who own a touch device to have a look?

I tried with latest nightly and its the same.

Thanks

timunie commented 1 year ago

ping @emmauss do you have any ideas here?