Class VelocityTracker
Definition
- Assembly:
- Tizen.NUI.dll
Calculates the velocity of touch movements over time.
public class VelocityTracker
- Inheritance
-
objectVelocityTracker
Examples
private void OnPanGestureDetected(object source, PanGestureDetector.DetectedEventArgs e) { tracker.AddMovement(e.PanGesture.ScreenPosition, e.PanGesture.Time); if (e.PanGesture.State == Gesture.StateType.Started) { } else if (e.PanGesture.State == Gesture.StateType.Continuing) { } else if (e.PanGesture.State == Gesture.StateType.Finished || e.PanGesture.State == Gesture.StateType.Cancelled) { float panVelocity = (ScrollingDirection == Direction.Horizontal) ? tracker.GetVelocity().X : tracker.GetVelocity().Y; tracker.Clear(); } }
Constructors
View SourceVelocityTracker(int)
Creates a velocity tracker using the specified strategy.
Declaration
public VelocityTracker(int degree = 2)
Parameters
| Type | Name | Description |
|---|---|---|
| int | degree |
VelocityTracker(VelocityTrackerStrategy[])
Declaration
public VelocityTracker(VelocityTrackerStrategy[] strategy)
Parameters
| Type | Name | Description |
|---|---|---|
| VelocityTrackerStrategy[] | strategy |
Examples
private void OnPanGestureDetected(object source, PanGestureDetector.DetectedEventArgs e) { tracker.AddMovement(e.PanGesture.ScreenPosition, e.PanGesture.Time); if (e.PanGesture.State == Gesture.StateType.Started) { } else if (e.PanGesture.State == Gesture.StateType.Continuing) { } else if (e.PanGesture.State == Gesture.StateType.Finished || e.PanGesture.State == Gesture.StateType.Cancelled) { float panVelocity = (ScrollingDirection == Direction.Horizontal) ? tracker.GetVelocity().X : tracker.GetVelocity().Y; tracker.Clear(); } }
Methods
View SourceAddMovement(Vector2, uint)
Adds movement information
Declaration
public void AddMovement(Vector2 position, uint eventTime)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | position | |
| uint | eventTime |
Clear()
Resets the velocity tracker state.
Declaration
public void Clear()
ComputeVelocity(int, float)
Compute the current velocity based on the points that have been collected.
Declaration
public void ComputeVelocity(int units, float maxVelocity)
Parameters
| Type | Name | Description |
|---|---|---|
| int | units | The units you would like the velocity in. A value of 1 provides units per millisecond, 1000 provides units per second. |
| float | maxVelocity | The maximum velocity that can be computed by this method. |
GetVelocity()
Retrieve the last computed velocity.
Declaration
public Vector2 GetVelocity()
Returns
| Type | Description |
|---|---|
| Vector2 |