Skip to content

Commit

Permalink
Rewrite card update to fix #7
Browse files Browse the repository at this point in the history
  • Loading branch information
robinmanuelthiel committed Feb 15, 2018
1 parent 8ea0369 commit 40aa190
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Binary file added .mfractor/.swipecards.db
Binary file not shown.
17 changes: 9 additions & 8 deletions SwipeCards.Controls/Views/CardStackView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,6 @@ async void OnPanUpdated(object sender, PanUpdatedEventArgs e)
//case GestureStatus.Canceled:
await HandleTouchCompleted();
break;
default:
break;
}
}

Expand Down Expand Up @@ -305,17 +303,20 @@ private void ShowNextCard()
topCard.Scale = defaultSubcardScale;
CardStack.Children.Insert(0, topCard);
}

// Update cards
for (int i = 0; i < Math.Min(numberOfCards, ItemsSource.Count); i++)

// Update cards from top to back
// Start with the first card on top with is the last one on the CardStack
for (var i = numberOfCards - 1; i >= 0; i--)
{
var cardView = (CardView)CardStack.Children[i];
cardView.Rotation = 0;
cardView.TranslationX = 0;

if ((itemIndex + 1) - i < ItemsSource.Count)
{
cardView.Update(ItemsSource[(itemIndex + 1) - i]);
// Check if an item for the card is available
var index = Math.Min((numberOfCards - 1), ItemsSource.Count) - i + itemIndex;
if (ItemsSource.Count > index)
{
cardView.Update(ItemsSource[index]);
cardView.IsVisible = true;
}
}
Expand Down

0 comments on commit 40aa190

Please sign in to comment.