Class SwipeView
A SwipeView is a container that displays one or more children at a time and provides a UI to navigate between them. It is similar to a ScrollView but here children are snapped to the container's edges. See PageView for a similar container that includes a page indicator.
Implements
Inherited Members
Namespace: Unity.AppUI.UI
Assembly: Unity.AppUI.dll
Syntax
public class SwipeView : BaseVisualElement, IEventHandler, ITransform, ITransitionAnimations, IExperimentalFeatures, IVisualElementScheduler, IResolvedStyle, IContextOverrideElement, IAdditionalDataHolder, INotifyValueChanged<int>
Constructors
SwipeView()
Default constructor.
Declaration
public SwipeView()
Fields
containerUssClassName
The styling class applied to the container of the SwipeView.
Declaration
public const string containerUssClassName = "appui-swipeview__container"
Field Value
Type | Description |
---|---|
string |
noAutoPlayDuration
The default duration of the auto play animation.
Declaration
public const int noAutoPlayDuration = -1
Field Value
Type | Description |
---|---|
int |
ussClassName
The main styling class of the SwipeView. This is the class that is used in the USS file.
Declaration
public const string ussClassName = "appui-swipeview"
Field Value
Type | Description |
---|---|
string |
variantUssClassName
The styling class applied to the SwipeView depending on its orientation.
Declaration
public const string variantUssClassName = "appui-swipeview--"
Field Value
Type | Description |
---|---|
string |
Properties
autoPlayDuration
The number of milliseconds between each automatic swipe.
Declaration
public int autoPlayDuration { get; set; }
Property Value
Type | Description |
---|---|
int |
bindItem
A method that is called when an item is bound to the SwipeView.
Declaration
public Action<SwipeViewItem, int> bindItem { get; set; }
Property Value
Type | Description |
---|---|
Action<SwipeViewItem, int> |
canGoToNext
Check if there is a next item or not.
Declaration
public bool canGoToNext { get; }
Property Value
Type | Description |
---|---|
bool |
canGoToPrevious
Check if there is a previous item or not.
Declaration
public bool canGoToPrevious { get; }
Property Value
Type | Description |
---|---|
bool |
contentContainer
The container of the SwipeView.
Declaration
public override VisualElement contentContainer { get; }
Property Value
Type | Description |
---|---|
VisualElement |
Overrides
count
The total number of items.
Declaration
public int count { get; }
Property Value
Type | Description |
---|---|
int |
currentItem
The current item.
Declaration
public SwipeViewItem currentItem { get; }
Property Value
Type | Description |
---|---|
SwipeViewItem |
direction
The orientation of the SwipeView.
Declaration
public Direction direction { get; set; }
Property Value
Type | Description |
---|---|
Direction |
resistance
The resistance of the SwipeView.
By default, the SwipeView has a resistance of 1.
If you set this property to more than 1, the SwipeView will be harder to swipe. If you set this property to less than 1, the SwipeView will be easier to swipe.
Declaration
public float resistance { get; set; }
Property Value
Type | Description |
---|---|
float |
skipAnimationThreshold
This property determines the threshold at which the animation will be skipped.
Declaration
public int skipAnimationThreshold { get; set; }
Property Value
Type | Description |
---|---|
int |
snapAnimationEasing
The easing of the animation when snapping to an item.
Declaration
public Func<float, float> snapAnimationEasing { get; set; }
Property Value
Type | Description |
---|---|
Func<float, float> |
snapAnimationSpeed
The speed of the animation when snapping to an item.
Declaration
public float snapAnimationSpeed { get; set; }
Property Value
Type | Description |
---|---|
float |
sourceItems
The source of items that are used to populate the SwipeView.
Declaration
public IList sourceItems { get; set; }
Property Value
Type | Description |
---|---|
IList |
startSwipeThreshold
The amount of pixels that must be swiped before the SwipeView begins to swipe.
Declaration
public float startSwipeThreshold { get; set; }
Property Value
Type | Description |
---|---|
float |
swipeable
Whether or not the SwipeView is swipeable.
By default, the SwipeView is swipeable. If you set this property to false, you won't be able to interact with the SwipeView (except programmatically).
Declaration
public bool swipeable { get; set; }
Property Value
Type | Description |
---|---|
bool |
unbindItem
A method that is called when an item is unbound from the SwipeView.
Declaration
public Action<SwipeViewItem, int> unbindItem { get; set; }
Property Value
Type | Description |
---|---|
Action<SwipeViewItem, int> |
value
The value of the SwipeView (i.e. the index of the current item).
Declaration
public int value { get; set; }
Property Value
Type | Description |
---|---|
int |
visibleItemCount
The number of items that are visible at the same time.
Declaration
public int visibleItemCount { get; set; }
Property Value
Type | Description |
---|---|
int |
wrap
This property determines whether or not the view wraps around when it reaches the start or end.
Declaration
public bool wrap { get; set; }
Property Value
Type | Description |
---|---|
bool |
Methods
GetDirectionUssClassName(Direction)
Declaration
public static string GetDirectionUssClassName(Direction enumValue)
Parameters
Type | Name | Description |
---|---|---|
Direction | enumValue |
Returns
Type | Description |
---|---|
string |
GoTo(int)
Go to item at index.
Declaration
public bool GoTo(int index)
Parameters
Type | Name | Description |
---|---|---|
int | index | Index of the item to go to. |
Returns
Type | Description |
---|---|
bool | True if the operation was successful, false otherwise. |
GoToNext()
Go to next item.
Declaration
public bool GoToNext()
Returns
Type | Description |
---|---|
bool | True if the operation was successful, false otherwise. |
GoToPrevious()
Go to previous item.
Declaration
public bool GoToPrevious()
Returns
Type | Description |
---|---|
bool | True if the operation was successful, false otherwise. |
SetValueWithoutNotify(int)
Sets the value without notifying the listeners.
Declaration
public void SetValueWithoutNotify(int newValue)
Parameters
Type | Name | Description |
---|---|---|
int | newValue | The new value. |
SnapTo(int)
Snap to item at index.
Declaration
public bool SnapTo(int index)
Parameters
Type | Name | Description |
---|---|---|
int | index | Index of the item to snap to. |
Returns
Type | Description |
---|---|
bool | True if the operation was successful, false otherwise. |
Events
beingSwiped
The event that is called when the value of the SwipeView changes (i.e. when its being swiped or when it snaps to an item).
Declaration
public event Action<SwipeViewItem, float> beingSwiped
Event Type
Type | Description |
---|---|
Action<SwipeViewItem, float> |