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 @@ -19,8 +19,6 @@ private class OnControlScrollChangedListener : RecyclerView.OnScrollListener
private CancellationTokenSource _cts;
private int _lastVisibleItemIndex = -1;

private int _currentOffset = 0;

public OnControlScrollChangedListener(IntPtr handle, JniHandleOwnership transfer)
: base(handle, transfer)
{
Expand All @@ -38,7 +36,23 @@ public override void OnScrolled(RecyclerView recyclerView, int dx, int dy)
{
base.OnScrolled(recyclerView, dx, dy);

_currentOffset += dx;
if (dx > 0)
{
_element.ScrollingRightCommand?.Execute(null);
}
else if (dx < 0)
{
_element.ScrollingLeftCommand?.Execute(null);
}

if (dy > 0)
{
_element.ScrollingDownCommand?.Execute(null);
}
else if (dy < 0)
{
_element.ScrollingUpCommand?.Execute(null);
}

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

public static readonly BindableProperty ScrollingLeftCommandProperty = BindableProperty.Create(
nameof(ScrollingLeftCommand),
typeof(ICommand),
typeof(CollectionView));

public static readonly BindableProperty ScrollingUpCommandProperty = BindableProperty.Create(
nameof(ScrollingUpCommand),
typeof(ICommand),
typeof(CollectionView));

public static readonly BindableProperty ScrollingRightCommandProperty = BindableProperty.Create(
nameof(ScrollingRightCommand),
typeof(ICommand),
typeof(CollectionView));

public static readonly BindableProperty ScrollingDownCommandProperty = BindableProperty.Create(
nameof(ScrollingDownCommand),
typeof(ICommand),
typeof(CollectionView));

public static readonly BindableProperty EnableDragAndDropProperty = BindableProperty.Create(
nameof(EnableDragAndDrop),
typeof(bool),
Expand Down Expand Up @@ -317,6 +337,30 @@ public ICommand ScrollEndedCommand
set => SetValue(ScrollEndedCommandProperty, value);
}

public ICommand ScrollingLeftCommand
{
get => (ICommand)GetValue(ScrollingLeftCommandProperty);
set => SetValue(ScrollingLeftCommandProperty, value);
}

public ICommand ScrollingUpCommand
{
get => (ICommand)GetValue(ScrollingUpCommandProperty);
set => SetValue(ScrollingUpCommandProperty, value);
}

public ICommand ScrollingDownCommand
{
get => (ICommand)GetValue(ScrollingDownCommandProperty);
set => SetValue(ScrollingDownCommandProperty, value);
}

public ICommand ScrollingRightCommand
{
get => (ICommand)GetValue(ScrollingRightCommandProperty);
set => SetValue(ScrollingRightCommandProperty, value);
}

public bool EnableDragAndDrop
{
get => (bool)GetValue(EnableDragAndDropProperty);
Expand Down