本文整理汇总了C#中UIPanGestureRecognizer.VelocityInView方法的典型用法代码示例。如果您正苦于以下问题:C# UIPanGestureRecognizer.VelocityInView方法的具体用法?C# UIPanGestureRecognizer.VelocityInView怎么用?C# UIPanGestureRecognizer.VelocityInView使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UIPanGestureRecognizer
的用法示例。
在下文中一共展示了UIPanGestureRecognizer.VelocityInView方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnPanningGesture
private void OnPanningGesture (UIPanGestureRecognizer gesture)
{
switch (gesture.State) {
case UIGestureRecognizerState.Began:
panStart = gesture.TranslationInView (actualContentView);
panLockInHorizDirection = false;
break;
case UIGestureRecognizerState.Changed:
var currentPoint = gesture.TranslationInView (actualContentView);
panDeltaX = panStart.X - currentPoint.X;
if (panDeltaX > 0) {
panDeltaX = 0;
return;
}
if (!panLockInHorizDirection) {
if (Math.Abs (panDeltaX) > 30) {
// User is swiping the cell, lock them into this direction
panLockInHorizDirection = true;
} else if (Math.Abs (panStart.Y - currentPoint.Y) > 5) {
// User is starting to move upwards, let them scroll
gesture.Enabled = false;
}
}
if (-SwipeWidth > panDeltaX) {
panDeltaX = -SwipeWidth;
}
UIView.AnimateNotify (0.1, 0, UIViewAnimationOptions.CurveEaseOut, LayoutActualContentView, null);
break;
case UIGestureRecognizerState.Ended:
if (Editing) {
break;
}
if (!gesture.Enabled) {
gesture.Enabled = true;
}
var velocityX = gesture.VelocityInView (gesture.View).X;
var absolutePanDeltaX = Math.Abs (panDeltaX);
var duration = Math.Max (MinDuration, Math.Min (MaxDuration, (absolutePanDeltaX) / velocityX));
UIView.AnimateNotify (duration, () => LayoutActualContentView (0), isFinished => {
if (isFinished && absolutePanDeltaX > SwipeWidth - 5) {
OnContinueGestureFinished ();
}
});
break;
case UIGestureRecognizerState.Cancelled:
UIView.AnimateNotify (0.3, () => LayoutActualContentView (0), isFinished => gesture.Enabled = isFinished);
break;
}
}
示例2: NodeTouchEvent
public NodeTouchEvent(NodeUIView parent, UIPanGestureRecognizer pan)
{
switch (pan.State) {
case UIGestureRecognizerState.Began:
type = TouchType.Down;
break;
case UIGestureRecognizerState.Changed:
type = TouchType.Move;
break;
case UIGestureRecognizerState.Ended:
type = TouchType.Up;
break;
case UIGestureRecognizerState.Possible:
case UIGestureRecognizerState.Cancelled:
case UIGestureRecognizerState.Failed:
break;
}
var p = pan.LocationInView (parent);
point = new Point (p.X, p.Y);
var velo = pan.VelocityInView (parent);
velocity = new Vec2 (velo.X / 1000, velo.Y / 1000);
}
示例3: Panned
private void Panned(UIPanGestureRecognizer gestureRecognizer)
{
if (this.items.Count < 2 || this.contentWidth <= this.View.Bounds.Width)
{
return;
}
// quick hack for nested panoramas
if (this.presentedController is UIPanoramaViewController)
{
return;
}
var panLocation = gestureRecognizer.TranslationInView(this.ContentView);
var offset = this.currentScrolledOffset - panLocation.X;
// this is the total amount that we've scrolled away from zero
this.LayoutContent(this.LimitOffset(offset));
if (gestureRecognizer.State != UIGestureRecognizerState.Ended)
{
return;
}
var velocity = gestureRecognizer.VelocityInView(this.View).X;
if (Math.Abs(velocity) < 700)
{
this.currentScrolledOffset = this.CalculatePannedLocation(offset, panLocation.X);
this.ScrollContent(currentScrolledOffset);
}
else
{
if (panLocation.X < 0)
{
var proposedOffset = this.GetNextOffset(offset);
this.currentScrolledOffset = proposedOffset;
}
else
{
var proposedOffset = this.GetPriorOffset(offset);
this.currentScrolledOffset = proposedOffset;
}
this.ScrollContent(this.currentScrolledOffset);
}
gestureRecognizer.SetTranslation(PointF.Empty, this.View);
}
示例4: PanGestureRecognized
//.........这里部分代码省略.........
if (!_bouncesHorizontally && Visible) {
if (_contentViewContainer.Frame.Location.X > _contentViewContainer.Frame.Size.Width / 2.0)
point.X = Math.Min(0.0F, point.X);
if (_contentViewContainer.Frame.Location.X < -(_contentViewContainer.Frame.Size.Width / 2.0))
point.X = Math.Max(0.0F, point.X);
}
// Limit size
//
if (point.X < 0) {
point.X = Math.Max(point.X, - UIScreen.MainScreen.Bounds.Size.Height);
} else {
point.X = Math.Min(point.X, UIScreen.MainScreen.Bounds.Size.Height);
}
recognizer.SetTranslation (point, View);
if (!_didNotifyDelegate) {
if (point.X > 0) {
// if (!Visible && [self.delegate conformsToProtocol:@protocol(RESideMenuDelegate)] && [self.delegate respondsToSelector:@selector(sideMenu:willShowMenuViewController:)]) {
// [self.delegate sideMenu:self willShowMenuViewController:self.leftMenuViewController];
// }
}
if (point.X < 0) {
// if (!self.visible && [self.delegate conformsToProtocol:@protocol(RESideMenuDelegate)] && [self.delegate respondsToSelector:@selector(sideMenu:willShowMenuViewController:)]) {
// //[self.delegate sideMenu:self willShowMenuViewController:self.rightMenuViewController];
// }
}
_didNotifyDelegate = true;
}
if (contentViewScale > 1) {
float oppositeScale = (1 - (contentViewScale - 1));
_contentViewContainer.Transform = CGAffineTransform.MakeScale(oppositeScale, oppositeScale);
_contentViewContainer.Transform = CGAffineTransform.Translate(_contentViewContainer.Transform, point.X, 0);
} else {
_contentViewContainer.Transform = CGAffineTransform.MakeScale(contentViewScale, contentViewScale);
_contentViewContainer.Transform = CGAffineTransform.Translate(_contentViewContainer.Transform, point.X, 0);
}
if (_leftMenuViewController != null)
_leftMenuViewController.View.Hidden = _contentViewContainer.Frame.Location.X < 0;
if (_rightMenuViewController != null)
_rightMenuViewController.View.Hidden = _contentViewContainer.Frame.Location.X > 0;
if (_leftMenuViewController == null && _contentViewContainer.Frame.Location.X > 0) {
_contentViewContainer.Transform = CGAffineTransform.MakeIdentity();
_contentViewContainer.Frame = View.Bounds;
Visible = false;
_leftMenuVisible = false;
} else if (_rightMenuViewController == null && _contentViewContainer.Frame.Location.X < 0) {
_contentViewContainer.Transform = CGAffineTransform.MakeIdentity();
_contentViewContainer.Frame = View.Bounds;
Visible = false;
_rightMenuVisible = false;
}
StatusBarNeedsAppearanceUpdate ();
}
if (recognizer.State == UIGestureRecognizerState.Ended) {
_didNotifyDelegate = false;
if (_leftMenuViewController != null)
_leftMenuViewController.View.Hidden = false;
if (_rightMenuViewController != null)
_rightMenuViewController.View.Hidden = false;
if (_panMinimumOpenThreshold > 0 && (
(_contentViewContainer.Frame.Location.X < 0 && _contentViewContainer.Frame.Location.X > -((int)_panMinimumOpenThreshold)) ||
(_contentViewContainer.Frame.Location.X > 0 && _contentViewContainer.Frame.Location.X < _panMinimumOpenThreshold))
) {
HideMenuViewController (this, null);
}
else if (_contentViewContainer.Frame.Location.X == 0) {
HideMenuViewControllerAnimated(false);
}
else {
if (recognizer.VelocityInView(View).X > 0) {
if (_contentViewContainer.Frame.Location.X < 0) {
HideMenuViewController (this, null);
} else {
if (_leftMenuViewController != null) {
ShowLeftMenuViewController ();
}
}
} else {
if (_contentViewContainer.Frame.Location.X < 20) {
if (_rightMenuViewController != null) {
ShowRightMenuViewController ();
}
} else {
HideMenuViewController (this, null);
}
}
}
}
}
示例5: HandleDrag
void HandleDrag(UIPanGestureRecognizer sender)
{
switch (sender.State)
{
case UIGestureRecognizerState.Began:
startPos = this.Center;
// Determines if the view can be pulled in the x or y axis
verticalAxis = closedCenter.X == openedCenter.X;
// Finds the minimum and maximum points in the axis
if (verticalAxis)
{
minPos = closedCenter.Y < openedCenter.Y ? closedCenter : openedCenter;
maxPos = closedCenter.Y > openedCenter.Y ? closedCenter : openedCenter;
}
else
{
minPos = closedCenter.X < openedCenter.X ? closedCenter : openedCenter;
maxPos = closedCenter.X > openedCenter.X ? closedCenter : openedCenter;
}
break;
case UIGestureRecognizerState.Changed:
PointF translate = sender.TranslationInView(this.Superview);
PointF newPos;
// Moves the view, keeping it constrained between openedCenter and closedCenter
if (verticalAxis)
{
newPos = new PointF(startPos.X, startPos.Y + translate.Y);
if (newPos.Y < minPos.Y)
{
newPos.Y = minPos.Y;
translate = new PointF(0, newPos.Y - startPos.Y);
}
if (newPos.Y > maxPos.Y)
{
newPos.Y = maxPos.Y;
translate = new PointF(0, newPos.Y - startPos.Y);
}
}
else
{
newPos = new PointF(startPos.X + translate.X, startPos.Y);
if (newPos.X < minPos.X)
{
newPos.X = minPos.X;
translate = new PointF(newPos.X - startPos.X, 0);
}
if (newPos.X > maxPos.X)
{
newPos.X = maxPos.X;
translate = new PointF(newPos.X - startPos.X, 0);
}
}
sender.SetTranslation(translate, this.Superview);
this.Center = newPos;
break;
case UIGestureRecognizerState.Ended:
PointF vectorVelocity = sender.VelocityInView(this.Superview);
float axisVelocity = verticalAxis ? vectorVelocity.Y : vectorVelocity.X;
PointF target = axisVelocity < 0 ? minPos : maxPos;
bool op = target == openedCenter ? true : false;
this.SetOpenedAnimated(op, animate);
break;
}
}
示例6: Panned
//.........这里部分代码省略.........
}
}
if (x < 0)
{
bool canOpen = true;
if (this.Delegate != null)
{
canOpen = this.Delegate.WillOpenRightView(this, false);
didOpenSelector = () => this.Delegate.DidOpenRightView(this, false);
}
if (!canOpen)
{
this.CloseLeftView(false);
return;
}
}
}
this.SetSlidingFrameForOffset(x);
if (this.Delegate != null)
{
this.Delegate.DidPanToOffset(this, x);
}
if (panner.State == UIGestureRecognizerState.Ended)
{
if (this.SlidingControllerView.Frame.Location.X == 0.0f)
{
this.CenterViewVisible();
}
else
{
this.CenterViewHidden();
}
nfloat lw3 = (w - this.LeftLedge) / 3.0f;
nfloat rw3 = (w - this.RightLedge) / 3.0f;
nfloat velocity = panner.VelocityInView(this.referenceView).X;
if (Math.Abs(velocity) < 500)
{
// small velocity, no movement
if (x >= w - this.LeftLedge - lw3)
{
this.OpenLeftView(true, UIViewAnimationOptions.CurveEaseOut, false, null);
}
else if (x <= this.RightLedge + rw3 - w)
{
this.OpenRightView(true, UIViewAnimationOptions.CurveEaseOut, false, null);
}
else
{
this.ShowCenterView(true);
}
}
else if (velocity < 0)
{
// swipe to the left
if (x < 0)
{
this.OpenRightView(true, UIViewAnimationOptions.CurveEaseOut, true, null);
}
else
{
this.ShowCenterView(true);
}
}
else if (velocity > 0)
{
// swipe to the right
if (x > 0)
{
this.OpenLeftView(true, UIViewAnimationOptions.CurveEaseOut, true, null);
}
else
{
this.ShowCenterView(true);
}
}
}
else
{
this.HideAppropriateSideViews();
}
if (didCloseSelector != null)
{
didCloseSelector();
}
if (didOpenSelector != null)
{
didOpenSelector();
}
}
示例7: DragContentView
public void DragContentView(UIPanGestureRecognizer panGesture)
{
if (ShouldStayOpen || mainView == null)
return;
var frame = mainView.Frame;
var translation = panGesture.TranslationInView (View).Y;
//Console.WriteLine (translation);
if (panGesture.State == UIGestureRecognizerState.Began) {
startY = frame.Y;
} else if (panGesture.State == UIGestureRecognizerState.Changed) {
frame.Y = translation + startY;
if (frame.Y < 0)
frame.Y = 0;
else if (frame.Y > frame.Height)
frame.Y = menuHeight;
SetLocation(frame);
} else if (panGesture.State == UIGestureRecognizerState.Ended) {
var velocity = panGesture.VelocityInView(View).Y;
//Console.WriteLine (velocity);
var newY = translation + startY;
Console.WriteLine (translation + startY);
bool show = (Math.Abs(velocity) > sidebarFlickVelocity)
? (velocity > 0)
: startY < menuHeight ? (newY > (menuHeight / 2)) : newY > menuHeight;
if(show)
ShowMenu();
else
HideMenu();
}
}
示例8: DragContentView
public void DragContentView(UIPanGestureRecognizer panGesture)
{
if (ShouldStayOpen || mainView == null)
return;
if (!HideShadow)
View.InsertSubviewBelow(shadowView, mainView);
navigation.View.Hidden = false;
RectangleF frame = mainView.Frame;
shadowView.Frame = frame;
float translation = panGesture.TranslationInView(View).X;
if (panGesture.State == UIGestureRecognizerState.Began)
{
startX = frame.X;
}
else if (panGesture.State == UIGestureRecognizerState.Changed)
{
frame.X = translation + startX;
if (Position == FlyOutNavigationPosition.Left)
{
if (frame.X < 0)
frame.X = 0;
else if (frame.X > menuWidth)
frame.X = menuWidth;
}
else
{
if (frame.X > 0)
frame.X = 0;
else if (frame.X < -menuWidth)
frame.X = -menuWidth;
}
SetLocation(frame);
}
else if (panGesture.State == UIGestureRecognizerState.Ended)
{
float velocity = panGesture.VelocityInView(View).X;
float newX = translation + startX;
bool show = Math.Abs (velocity) > sidebarFlickVelocity ? velocity > 0 : newX > (menuWidth / 2);
if (Position == FlyOutNavigationPosition.Right) {
show = Math.Abs(velocity) > sidebarFlickVelocity ? velocity < 0 : newX < -(menuWidth / 2);
}
if (show) {
ShowMenu ();
} else {
HideMenu ();
}
}
}
示例9: OnPanGesture
void OnPanGesture(UIPanGestureRecognizer obj)
{
switch( obj.State )
{
case UIGestureRecognizerState.Began:
{
// when panning begins, clear our pan values
PanLastPos = new CGPoint( 0, 0 );
PanDir = 0;
break;
}
case UIGestureRecognizerState.Changed:
{
// use the velocity to determine the direction of the pan
CGPoint currVelocity = obj.VelocityInView( View );
if( currVelocity.X < 0 )
{
PanDir = -1;
}
else
{
PanDir = 1;
}
// Update the positions of the cards
CGPoint absPan = obj.TranslationInView( View );
CGPoint delta = new CGPoint( absPan.X - PanLastPos.X, 0 );
PanLastPos = absPan;
TryPanSpringboard( delta );
break;
}
case UIGestureRecognizerState.Ended:
{
CGPoint currVelocity = obj.VelocityInView( View );
float restingPoint = (float)0.00f;//(View.Layer.Bounds.Width / 2);
float currX = (float) (View.Layer.Position.X - restingPoint);
// if they slide at least a third of the way, allow a switch
float toggleThreshold = (PrivatePrimaryContainerConfig.SlideAmount_iOS / 3);
// check whether the springboard is open, because that changes the
// context of hte user's intention
if( SpringboardRevealed == true )
{
// since it's open, close it if it crosses the closeThreshold
// OR velocty is high
float closeThreshold = PrivatePrimaryContainerConfig.SlideAmount_iOS - toggleThreshold;
if( currX < closeThreshold || currVelocity.X < -1000 )
{
RevealSpringboard( false );
}
else
{
RevealSpringboard( true );
}
}
else
{
// since it's closed, allow it to open as long as it's beyond toggleThreshold
// OR velocity is high
if( currX > toggleThreshold || currVelocity.X > 1000 )
{
RevealSpringboard( true );
}
else
{
RevealSpringboard( false );
}
}
break;
}
}
}
示例10: HandlePan
private void HandlePan(UIPanGestureRecognizer rec)
{
if (rec.State == UIGestureRecognizerState.Began)
{
HandleTouchesBeganAtLocation(rec.LocationInView(View));
}
else if (rec.State == UIGestureRecognizerState.Changed)
{
HandleTouchesMovedToLocation(rec.LocationInView(View));
}
else if (rec.State == UIGestureRecognizerState.Ended ||
rec.State == UIGestureRecognizerState.Cancelled ||
rec.State == UIGestureRecognizerState.Failed)
{
float velocity = rec.VelocityInView(View).X;
if (Math.Abs(velocity) > kLWMinimumVelocityToTriggerSlide)
{
if (velocity > 0f)
{
SlideOutSlideNavigationView();
}
else
{
SlideInSlideNavigationView();
}
}
else
{
HandleTouchesEndedAtLocation(rec.LocationInView(View));
}
}
}
示例11: OnPanned
private void OnPanned(UIPanGestureRecognizer panRecognizer)
{
PointF translation = panRecognizer.TranslationInView(View);
PointF velocity = panRecognizer.VelocityInView(View);
if (panRecognizer.State == UIGestureRecognizerState.Began)
{
_panVertical = (Math.Abs(velocity.Y) > Math.Abs(velocity.X));
if (_panVertical)
{
_panStartValue = _shimmeringView.ShimmeringSpeed;
}
else
{
_panStartValue = _shimmeringView.ShimmeringOpacity;
}
AnimateValueLabelVisible(true);
}
else if (panRecognizer.State == UIGestureRecognizerState.Changed)
{
float directional = (_panVertical ? translation.Y : translation.X);
float possible = (_panVertical ? View.Bounds.Size.Height : View.Bounds.Size.Width);
float progress = (directional / possible);
if (_panVertical)
{
_shimmeringView.ShimmeringSpeed = (float)Math.Max(0.0f, Math.Min(1000.0f, _panStartValue + progress * 200.0f));
_valueLabel.Text = string.Format("Speed\n{0:0.0}", _shimmeringView.ShimmeringSpeed);
}
else
{
_shimmeringView.ShimmeringOpacity = (float)Math.Max(0.0f, Math.Min(1.0f, _panStartValue + progress * 0.5f));
_valueLabel.Text = string.Format("Opacity\n{0:0.00}", _shimmeringView.ShimmeringOpacity);
}
}
else if (panRecognizer.State == UIGestureRecognizerState.Ended ||
panRecognizer.State == UIGestureRecognizerState.Cancelled)
{
AnimateValueLabelVisible(false);
}
}
示例12: dismissingPanGestureRecognizerPanned
private void dismissingPanGestureRecognizerPanned(UIPanGestureRecognizer panner)
{
if (Flags.ScrollViewIsAnimatingAZoom || Flags.IsAnimatingAPresentationOrDismissal)
return;
PointF translation = panner.TranslationInView (panner.View);
PointF locationInView = panner.LocationInView (panner.View);
PointF velocity = panner.VelocityInView (panner.View);
float vectorDistance = (float)Math.Sqrt (Math.Pow (velocity.X, 2) + Math.Pow (velocity.Y, 2));
if (panner.State == UIGestureRecognizerState.Began) {
Flags.IsDraggingImage = ImageView.Frame.Contains (locationInView);
if (Flags.IsDraggingImage)
StartImageDragging (locationInView, new UIOffset ());
} else if (panner.State == UIGestureRecognizerState.Changed) {
if (Flags.IsDraggingImage) {
PointF newAnchor = ImageDragStartingPoint;
newAnchor.X += translation.X + ImageDragOffsetFromActualTranslation.Horizontal;
newAnchor.Y += translation.Y + ImageDragOffsetFromActualTranslation.Vertical;
AttachmentBehavior.AnchorPoint = newAnchor;
} else {
Flags.IsDraggingImage = ImageView.Frame.Contains (locationInView);
if (Flags.IsDraggingImage) {
UIOffset translationOffset = new UIOffset (-1 * translation.X, -1 * translation.Y);
StartImageDragging (locationInView, translationOffset);
}
}
} else {
if (vectorDistance > JTSImageViewController.JTSImageViewController_MinimumFlickDismissalVelocity) {
if (Flags.IsDraggingImage) {
DismissImageWithFlick (velocity);
} else {
Dismiss (true);
}
} else {
CancelCurrentImageDrag (true);
}
}
}
示例13: DragContentView
public void DragContentView (UIPanGestureRecognizer panGesture)
{
float translation = (float) panGesture.TranslationInView (View).X;
if (panGesture.State == UIGestureRecognizerState.Changed) {
if (SidebarShowing) {
if (translation > 0.0f) {
_contentView.Frame = _contentView.Bounds
#if __UNIFIED__
#else
.OffsetNew (kGHRevealSidebarWidth, 0.0f)
#endif
;
SidebarShowing = true;
} else if (translation < -kGHRevealSidebarWidth) {
_contentView.Frame = _contentView.Bounds;
SidebarShowing = false;
} else {
_contentView.Frame = _contentView.Bounds
#if __UNIFIED__
#else
.OffsetNew ((kGHRevealSidebarWidth + translation), 0.0f)
#endif
;
}
} else {
if (translation < 0.0f) {
_contentView.Frame = _contentView.Bounds;
#if __UNIFIED__
#else
SidebarShowing = false
#endif
;
} else if (translation > kGHRevealSidebarWidth) {
_contentView.Frame = _contentView.Bounds
#if __UNIFIED__
#else
.OffsetNew (kGHRevealSidebarWidth, 0.0f)
#endif
;
SidebarShowing = true;
} else {
_contentView.Frame = _contentView.Bounds
#if __UNIFIED__
#else
.OffsetNew (translation, 0.0f)
#endif
;
}
}
} else if (panGesture.State == UIGestureRecognizerState.Ended) {
float velocity = (float) panGesture.VelocityInView (View).X;
bool show = (Math.Abs (velocity) > kGHRevealSidebarFlickVelocity)
? (velocity > 0) : (translation > (kGHRevealSidebarWidth / 2));
ToggleSidebar (show, kGHRevealSidebarDefaultAnimationDuration);
}
}
示例14: DragContentView
public void DragContentView(UIPanGestureRecognizer panGesture)
{
if (ShouldStayOpen)
return;
var translation = panGesture.TranslationInView (View).X;
var frame = mainView.Bounds;
if (panGesture.State == UIGestureRecognizerState.Changed) {
if (IsOpen) {
if (translation > 0.0f) {
ShowMenu();
} else if (translation < - menuWidth) {
HideMenu();
} else {
frame.X = menuWidth + translation;
SetLocation(frame);
}
} else {
if (translation < 0.0f) {
HideMenu();
} else if (translation > menuWidth) {
ShowMenu();
} else {
frame.X = translation;
SetLocation(frame);
}
}
} else if (panGesture.State == UIGestureRecognizerState.Ended) {
var velocity = panGesture.VelocityInView(View).X;
bool show = (Math.Abs(velocity) > sidebarFlickVelocity)
? (velocity > 0)
: (translation > (menuWidth / 2));
if(show)
ShowMenu();
else
HideMenu();
}
}
示例15: PanRight
private void PanRight(UIPanGestureRecognizer panGesture)
{
var frame = mainView.Frame;
var translation = panGesture.TranslationInView(View).X;
//Console.WriteLine (translation);
if (panGesture.State == UIGestureRecognizerState.Began)
{
startX = frame.X;
}
else if (panGesture.State == UIGestureRecognizerState.Changed)
{
//don't allow getsture to close
if (!GestureToClose && (translation + startX) > startX)
translation = 0;
//don't allow gesture to open
if (!GestureToOpen && (translation + startX) < startX)
translation = 0;
frame.X = translation + startX;
if (frame.X < -menuWidth)
frame.X = -menuWidth;
else if (frame.X > 0)
frame.X = 0;
SetLocation(frame);
}
else if (panGesture.State == UIGestureRecognizerState.Ended)
{
var velocity = panGesture.VelocityInView(View).X;
//Console.WriteLine (velocity);
var newX = translation + startX;
Console.WriteLine(translation + startX);
bool show = (Math.Abs(velocity) > sidebarFlickVelocity)
? (velocity > 0)
: startX < menuWidth ? (newX > (menuWidth / 2)) : newX > menuWidth;
show = !show;//swap
//don't allow flick open
if (show && !GestureToOpen)
return;
//don't allow flick close
if (!show && !GestureToClose)
return;
if (show)
ShowMenu();
else
HideMenu();
}
}