This repository has been archived by the owner on May 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
Copy pathPinchGestureHandler.cs
58 lines (51 loc) · 1.67 KB
/
PinchGestureHandler.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using System;
using System.ComponentModel;
using ElmSharp;
namespace Xamarin.Forms.Platform.Tizen
{
public class PinchGestureHandler : GestureHandler
{
Point _currentScalePoint;
int _previousPinchRadius;
double _originalPinchScale;
public PinchGestureHandler(IGestureRecognizer recognizer) : base(recognizer)
{
}
public override GestureLayer.GestureType Type
{
get
{
return GestureLayer.GestureType.Zoom;
}
}
protected override void OnStarted(View sender, object data)
{
var geometry = Platform.GetRenderer(sender).NativeView.Geometry;
var zoomData = (GestureLayer.ZoomData)data;
_currentScalePoint = new Point((zoomData.X - geometry.X) / (double)geometry.Width, (zoomData.Y - geometry.Y) / (double)geometry.Height);
_originalPinchScale = sender.Scale;
_previousPinchRadius = zoomData.Radius;
(Recognizer as IPinchGestureController)?.SendPinchStarted(sender, _currentScalePoint);
}
protected override void OnMoved(View sender, object data)
{
var zoomData = (GestureLayer.ZoomData)data;
if (_previousPinchRadius <= 0)
_previousPinchRadius = 1;
// functionality limitation: _currentScalePoint is not updated
(Recognizer as IPinchGestureController)?.SendPinch(sender,
1 + _originalPinchScale * (zoomData.Radius - _previousPinchRadius) / _previousPinchRadius,
_currentScalePoint
);
_previousPinchRadius = zoomData.Radius;
}
protected override void OnCompleted(View sender, object data)
{
(Recognizer as IPinchGestureController)?.SendPinchEnded(sender);
}
protected override void OnCanceled(View sender, object data)
{
(Recognizer as IPinchGestureController)?.SendPinchCanceled(sender);
}
}
}