Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ public override void OnScrolled(RecyclerView recyclerView, int dx, int dy)

_currentOffset += dx;

if (_element.ForceToUpdateCurrentIndexDuringScroll && _weakNativeView.TryGetTarget(out CollectionViewRenderer nativeView))
{
_cts?.Cancel();
_cts = new CancellationTokenSource();
UpdateCurrentIndex(nativeView, _cts.Token);
}

var infiniteListLoader = _element?.InfiniteListLoader;
if (infiniteListLoader == null)
{
Expand Down
12 changes: 12 additions & 0 deletions Sharpnado.CollectionView/RenderedViews/CollectionView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,12 @@ public class CollectionView : View
typeof(CollectionView),
1);

public static readonly BindableProperty ForceToUpdateCurrentIndexDuringScrollProperty = BindableProperty.Create(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ForceUpdateCurrentIndexDuringScroll is a better name

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed

nameof(ForceToUpdateCurrentIndexDuringScroll),
typeof(bool),
typeof(CollectionView),
false);

public CollectionView()
{
// default layout is VerticalList
Expand Down Expand Up @@ -365,6 +371,12 @@ public int ColumnCount
set => SetValue(ColumnCountProperty, value);
}

public bool ForceToUpdateCurrentIndexDuringScroll
{
get => (bool)GetValue(ForceToUpdateCurrentIndexDuringScrollProperty);
set => SetValue(ForceToUpdateCurrentIndexDuringScrollProperty, value);
}

public Func<ViewCell, Task> PreRevealAnimationAsync { get; set; }

public Func<ViewCell, Task> RevealAnimationAsync { get; set; }
Expand Down