FAScrollSnapBehaviour Class

Provides functionalities for a ScrollRect that snaps.
[RequireComponent(typeof(ScrollRect))] 
public class FAScrollSnapBehaviour : IBeginDragHandler
IEndDragHandler
IDragHandler
This language is not supported or no code example is available.
Name Description
Public property DidInit Gets the initialization status of the FAScrollSnapBehaviour
Public property IsHorizontal Gets the scrolling orientation of the FAScrollSnapBehaviour
Public property IsLerping Returns true when the Scroll View is moved true button, and the movement is still in action.
Public property Items List of all FAScrollSnapItem child items.
Public property Velocity Get the scroll view velocity (velocity != 0 only when scroll view is dragged, when button is clicked velocity == 0)
Top
Methods
 
Name Description
Public method InvokeScrollEvents()
Public method LerpToPage(int) Smoothly lerps the Scroll View to the page at the given index.

Can be called on button click.

Public method OnBeginDrag(PointerEventData)
Public method OnDrag(PointerEventData)
Public method OnEndDrag(PointerEventData)
Public method SetScrollPosition(float)
Public method Setup() Setup can be called at any time to setup the behaviour.

Should be called on Start or when the number of items in the Scroll View changes.

Top
Classes
 
Name Description
Public class OnMouseDownEvent
Public class OnMouseUpEvent
Public class ScrollEndedEvent Occurs when scrolling has completely ended.

Useful for cleaning up effects and animations.

Public class ScrollEvent Occurs when the ScrollRect is scrolled.

The passed Vector2 argument holds the ScrollRect's content current anchoredPosition

Useful for doing animations on a single item and compare positions.

Public class ScrollPercentageEvent Occurs when the ScrollRect is scrolled.

The passed float argument holds the normalized value of the scrolled percentage.

0f means first page is selected. 1f means last page is selected.

Useful for doing animations on a group of items.

Public class ScrollStartedEvent Occurs when scrolling has started.
Public class ScrollToPageEvent Occurs when the ScrollView locks on a page and scrolls to it.

Useful for doing animations after a page was found and selected.

If buttons are used for navigation, this event occurs on Prev/Next button tap.

If scrolling with FAScrollSnapBehaviour.snapToFirst set to true, this occurs as soon as the dragging end.

If scrolling with FAScrollSnapBehaviour.snapToFirst set to false, this occurs after the scroll speed is slowed enough so it locks to a page.

Top
Fields
 
Name Description
Public field centerSelectedItem
Public field decelarationLimit When decelarating freely, Gets or sets how slowed should the scrolling speed be before snapping.
Public field decelerationRate
Public field fastSwipeThresholdDistance Gets or sets threshold time for fast swipe in (unscaled) pixels. Default is 50.
Public field fastSwipeThresholdTime Gets or sets the threshold time for fast swipe in seconds. Default is 0.3f.
Public field forceSize Gets or sets if the this forces to resize the item according to one of the multipliers. See widthMultiplier and heightMultiplier/>
Public field heightMultiplier Gets or sets how tall should one item be in relation to the ScrollRect Height.

1f means same height, 0.5f means half height.

Works only if ScrollRect is vertical.

Public field innerScrolls If you have inner scroll views that scroll in the opposite direction of this ScrollSnapRect, you should add them here so the Drag Event is propagaded to this ScrollSnapRect. Should be set in inspector, otherwise please initialize the List.
Public field nextButton Button to go to the next page (optional)
Public field onMouseDown
Public field onMouseUp
Public field onScrollEnded Occurs when scrolling has completely ended.

Useful for cleaning up effects and animations.

Public field onScrollStarted Occurs when scrolling has started.
Public field onScrollToPage Occurs when the ScrollView locks on a page and scrolls to it.

Useful for doing animations after a page was found and selected.

If buttons are used for navigation, this event occurs on Prev/Next button tap.

If scrolling with snapToFirst set to true, this occurs as soon as the dragging end.

If scrolling with snapToFirst set to false, this occurs after the scroll speed is slowed enough so it locks to a page.

Public field onScrolled Occurs when the ScrollRect is scrolled.

The passed Vector2 argument holds the ScrollRect's content current anchoredPosition

Useful for doing animations on a single item and compare positions.

Public field onScrolledPercentage Occurs when the ScrollRect is scrolled.

The passed float argument holds the normalized value of the scrolled percentage.

0f means first page is selected. 1f means last page is selected.

Useful for doing animations on a group of items.

Public field prevButton
Public field snapToFirst If true, will snap to the first item, if false, will decelarate freely then snap when decelarationLimit is reached.
Public field startingPage Gets or sets starting page index - starting from 0. Default is 0. Should be set before initialization
Public field widthMultiplier Gets or sets how wide should one item be in relation to the ScrollRect Width.

1f means same width, 0.5f means half width.

Works only if ScrollRect is horizontal.

Top

.NET Framework

Supported in: 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1

In this article

Definition