Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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.ForceUpdateCurrentIndexDuringScroll && _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 ForceUpdateCurrentIndexDuringScrollProperty = BindableProperty.Create(
nameof(ForceUpdateCurrentIndexDuringScroll),
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 ForceUpdateCurrentIndexDuringScroll
{
get => (bool)GetValue(ForceUpdateCurrentIndexDuringScrollProperty);
set => SetValue(ForceUpdateCurrentIndexDuringScrollProperty, value);
}

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

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