TizenFX
TizenFX copied to clipboard
[NUI] Add VelocityTracker
Description of Change
This is a utility that calculates velocity from consecutive touch coordinates.
Velocity can be calculated using the motion event coordinates of touch or pan gestures.
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();
}
}
You can use the tracker that NUI provides by default, or you can use a customTracker created by the developer.
// You can use custom trackers created by yourself
Tizen.NUI.Utility.VelocityTrackerStrategy[] strategy = new CustomVelocityTracker[2];
for(int i=0 ; i<2; i++)
{
strategy[i] = new CustomVelocityTracker();
}
customTracker = new Tizen.NUI.Utility.VelocityTracker(strategy);
// you can use default tracker
tracker = new Tizen.NUI.Utility.VelocityTracker();
...
public class CustomVelocityTracker : Tizen.NUI.Utility.VelocityTrackerStrategy
{
...
}
API Changes
- ACR: