Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Raname ItemPlacement to ScrollItemPlacement
Browse files Browse the repository at this point in the history
Rosuavio committed Jun 29, 2021
1 parent f06179d commit 51bbb4b
Showing 5 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Microsoft.Toolkit.Uwp.SampleApp/Models/Sample.cs
Original file line number Diff line number Diff line change
@@ -675,7 +675,7 @@ private static Type LookForTypeByName(string typeName)

// TODO Reintroduce graph controls
// typeof(UserToPersonConverter)) // Search in Microsoft.Toolkit.Graph.Controls
ItemPlacement.Default.GetType(), // Search in Microsoft.Toolkit.Uwp.UI
ScrollItemPlacement.Default.GetType(), // Search in Microsoft.Toolkit.Uwp.UI
EasingType.Default.GetType(), // Microsoft.Toolkit.Uwp.UI.Animations
ImageBlendMode.Multiply.GetType(), // Search in Microsoft.Toolkit.Uwp.UI.Media
Interaction.Enabled.GetType(), // Microsoft.Toolkit.Uwp.Input.GazeInteraction
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
using Microsoft.Toolkit.Uwp.UI;

// Scrolling with index
await MyGridView.SmoothScrollIntoViewWithIndexAsync(index: int, itemPlacement: ItemPlacement, disableAnimation: bool, scrollIfVisibile: bool, additionalHorizontalOffset: int, additionalVerticalOffset: int);
await MyGridView.SmoothScrollIntoViewWithIndexAsync(index: int, itemPlacement: ScrollItemPlacement, disableAnimation: bool, scrollIfVisibile: bool, additionalHorizontalOffset: int, additionalVerticalOffset: int);

// Scrolling with item
await MyGridView.SmoothScrollIntoViewWithItemAsync(item: object, itemPlacement: ItemPlacement, disableAnimation: bool, scrollIfVisibile: bool, additionalHorizontalOffset: int, additionalVerticalOffset: int);
await MyGridView.SmoothScrollIntoViewWithItemAsync(item: object, itemPlacement: ScrollItemPlacement, disableAnimation: bool, scrollIfVisibile: bool, additionalHorizontalOffset: int, additionalVerticalOffset: int);
Original file line number Diff line number Diff line change
@@ -42,13 +42,13 @@ private void Load()
var index = int.TryParse(IndexInput.Text, out var i) ? i : 0;
var itemPlacement = ItemPlacementInput.SelectedItem switch
{
"Default" => ItemPlacement.Default,
"Left" => ItemPlacement.Left,
"Top" => ItemPlacement.Top,
"Center" => ItemPlacement.Center,
"Right" => ItemPlacement.Right,
"Bottom" => ItemPlacement.Bottom,
_ => ItemPlacement.Default
"Default" => ScrollItemPlacement.Default,
"Left" => ScrollItemPlacement.Left,
"Top" => ScrollItemPlacement.Top,
"Center" => ScrollItemPlacement.Center,
"Right" => ScrollItemPlacement.Right,
"Bottom" => ScrollItemPlacement.Bottom,
_ => ScrollItemPlacement.Default
};

var disableAnimation = DisableAnimationInput.IsChecked ?? false;
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ public static partial class ListViewExtensions
/// <param name="additionalHorizontalOffset">Adds additional horizontal offset</param>
/// <param name="additionalVerticalOffset">Adds additional vertical offset</param>
/// <returns>Note: Even though this return <see cref="Task"/>, it will not wait until the scrolling completes</returns>
public static async Task SmoothScrollIntoViewWithIndexAsync(this ListViewBase listViewBase, int index, ItemPlacement itemPlacement = ItemPlacement.Default, bool disableAnimation = false, bool scrollIfVisible = true, int additionalHorizontalOffset = 0, int additionalVerticalOffset = 0)
public static async Task SmoothScrollIntoViewWithIndexAsync(this ListViewBase listViewBase, int index, ScrollItemPlacement itemPlacement = ScrollItemPlacement.Default, bool disableAnimation = false, bool scrollIfVisible = true, int additionalHorizontalOffset = 0, int additionalVerticalOffset = 0)
{
if (index > (listViewBase.Items.Count - 1))
{
@@ -122,7 +122,7 @@ public static async Task SmoothScrollIntoViewWithIndexAsync(this ListViewBase li
{
switch (itemPlacement)
{
case ItemPlacement.Default:
case ScrollItemPlacement.Default:
if (previousXOffset <= maxXPosition && previousXOffset >= minXPosition)
{
finalXPosition = previousXOffset + additionalHorizontalOffset;
@@ -151,29 +151,29 @@ public static async Task SmoothScrollIntoViewWithIndexAsync(this ListViewBase li

break;

case ItemPlacement.Left:
case ScrollItemPlacement.Left:
finalXPosition = maxXPosition + additionalHorizontalOffset;
finalYPosition = previousYOffset + additionalVerticalOffset;
break;

case ItemPlacement.Top:
case ScrollItemPlacement.Top:
finalXPosition = previousXOffset + additionalHorizontalOffset;
finalYPosition = maxYPosition + additionalVerticalOffset;
break;

case ItemPlacement.Center:
case ScrollItemPlacement.Center:
var centreX = (listViewBaseWidth - selectorItemWidth) / 2.0;
var centreY = (listViewBaseHeight - selectorItemHeight) / 2.0;
finalXPosition = maxXPosition - centreX + additionalHorizontalOffset;
finalYPosition = maxYPosition - centreY + additionalVerticalOffset;
break;

case ItemPlacement.Right:
case ScrollItemPlacement.Right:
finalXPosition = minXPosition + additionalHorizontalOffset;
finalYPosition = previousYOffset + additionalVerticalOffset;
break;

case ItemPlacement.Bottom:
case ScrollItemPlacement.Bottom:
finalXPosition = previousXOffset + additionalHorizontalOffset;
finalYPosition = minYPosition + additionalVerticalOffset;
break;
@@ -199,7 +199,7 @@ public static async Task SmoothScrollIntoViewWithIndexAsync(this ListViewBase li
/// <param name="additionalHorizontalOffset">Adds additional horizontal offset</param>
/// <param name="additionalVerticalOffset">Adds additional vertical offset</param>
/// <returns>Note: Even though this return <see cref="Task"/>, it will not wait until the scrolling completes</returns>
public static async Task SmoothScrollIntoViewWithItemAsync(this ListViewBase listViewBase, object item, ItemPlacement itemPlacement = ItemPlacement.Default, bool disableAnimation = false, bool scrollIfVisibile = true, int additionalHorizontalOffset = 0, int additionalVerticalOffset = 0)
public static async Task SmoothScrollIntoViewWithItemAsync(this ListViewBase listViewBase, object item, ScrollItemPlacement itemPlacement = ScrollItemPlacement.Default, bool disableAnimation = false, bool scrollIfVisibile = true, int additionalHorizontalOffset = 0, int additionalVerticalOffset = 0)
{
await SmoothScrollIntoViewWithIndexAsync(listViewBase, listViewBase.Items.IndexOf(item), itemPlacement, disableAnimation, scrollIfVisibile, additionalHorizontalOffset, additionalVerticalOffset);
}
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ namespace Microsoft.Toolkit.Uwp.UI
/// <summary>
/// Item Position
/// </summary>
public enum ItemPlacement
public enum ScrollItemPlacement
{
/// <summary>
/// If visible then it will not scroll, if not then item will be aligned to the nearest edge

0 comments on commit 51bbb4b

Please sign in to comment.