- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 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
private readonly ScrollViewer _gestureListener = new ScrollViewer
{
Background = new SolidColorBrush { Color = Colors.Transparent },
Content = new Rectangle { Height = 5000 },
HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled,
VerticalScrollBarVisibility = ScrollBarVisibility.Hidden,
IsScrollInertiaEnabled = false,
};
private async void _gestureListener_ViewChanged(object sender, ScrollViewerViewChangedEventArgs e)
{
if (_flipLock) return;
var threshold = ActualHeight > 320 ? 48 : 32;
var delta = 2500 - _gestureListener.VerticalOffset;
if (e.IsIntermediate)
{
var abs = Math.Abs(delta);
var hit = abs > threshold;
var transparency = hit ? 0.5 : 1;
var currentDot = _counterCanvas.Children[SelectedIndex] as FrameworkElement;
var predictedDot = _counterCanvas.Children[delta > 0 ? PrevIndex : NextIndex] as FrameworkElement;
await AwaitAll(
_layer1Control.TranslateByYAsync(TimeSpan.Zero, null, -abs),
_layer1Control.ChangeOpacityAsync(MidAnimationLength, null, transparency),
_layer2Control.TranslateByYAsync(TimeSpan.Zero, null, abs),
_layer2Control.ChangeOpacityAsync(MidAnimationLength, null, transparency),
currentDot.ScaleAsync(QuickAnimationLength, null, hit ? 0.7 : 1.3),
predictedDot.ScaleAsync(QuickAnimationLength, null, hit ? 1.6 : 1),
currentDot.ChangeOpacityAsync(QuickAnimationLength, null, hit ? 0.5 : 1),
predictedDot.ChangeOpacityAsync(QuickAnimationLength, null, hit ? 1 : 0.5));
}
else
{
HandleGesture(delta, threshold);
}
}
private void HandleGesture(double delta, double threshold)
{
var down = delta < -threshold;
var up = delta > threshold;
if (down) FlipForward();
if (up) FlipBackward();
if (!down && !up) ResetPosition();
}
Комментарии (0) RSS
Добавить комментарий