Durmuş Ali Çöllü 2018-11-13 02:32:14 +01:00
parent c844807864
commit d9adaecfb7
2 changed files with 75 additions and 30 deletions

View File

@ -239,31 +239,54 @@ namespace UnityEngine.UI.Extensions
if (_scroll_rect.horizontal) if (_scroll_rect.horizontal)
{ {
var distance = Vector3.Distance(_startPosition, _screensContainer.localPosition); var distance = Vector3.Distance(_startPosition, _screensContainer.localPosition);
if ((UseFastSwipe && distance < panelDimensions.width && distance >= FastSwipeThreshold) || UseHardSwipe)
{ if(UseHardSwipe){
_scroll_rect.velocity = Vector3.zero; _scroll_rect.velocity = Vector3.zero;
if (_startPosition.x - _screensContainer.localPosition.x > 0)
if (distance > FastSwipeThreshold)
{ {
if (_startPosition.x - _screensContainer.localPosition.x > _childSize / 3) if (_startPosition.x - _screensContainer.localPosition.x > 0)
{
ScrollToClosestElement();
}
else
{ {
NextScreen(); NextScreen();
} }
}
else
{
if (_startPosition.x - _screensContainer.localPosition.x > -_childSize / 3)
{
ScrollToClosestElement();
}
else else
{ {
PreviousScreen(); PreviousScreen();
} }
} }
else
{
ScrollToClosestElement();
}
}
else
{
if (UseFastSwipe && distance < panelDimensions.width && distance >= FastSwipeThreshold )
{
_scroll_rect.velocity = Vector3.zero;
if (_startPosition.x - _screensContainer.localPosition.x > 0)
{
if (_startPosition.x - _screensContainer.localPosition.x > _childSize / 3)
{
ScrollToClosestElement();
}
else
{
NextScreen();
}
}
else
{
if (_startPosition.x - _screensContainer.localPosition.x > -_childSize / 3)
{
ScrollToClosestElement();
}
else
{
PreviousScreen();
}
}
}
} }
} }
} }

View File

@ -239,31 +239,53 @@ namespace UnityEngine.UI.Extensions
if (_scroll_rect.vertical) if (_scroll_rect.vertical)
{ {
var distance = Vector3.Distance(_startPosition, _screensContainer.localPosition); var distance = Vector3.Distance(_startPosition, _screensContainer.localPosition);
if ((UseFastSwipe && distance < panelDimensions.height + FastSwipeThreshold && distance >=1f) || UseHardSwipe) if(UseHardSwipe){
{
_scroll_rect.velocity = Vector3.zero; _scroll_rect.velocity = Vector3.zero;
if (_startPosition.y - _screensContainer.localPosition.y > 0)
if (distance > FastSwipeThreshold)
{ {
if (_startPosition.y - _screensContainer.localPosition.y > _childSize / 3) if (_startPosition.y - _screensContainer.localPosition.y > 0)
{
ScrollToClosestElement();
}
else
{ {
NextScreen(); NextScreen();
} }
}
else
{
if (_startPosition.y - _screensContainer.localPosition.y > -_childSize / 3)
{
ScrollToClosestElement();
}
else else
{ {
PreviousScreen(); PreviousScreen();
} }
} }
else
{
ScrollToClosestElement();
}
}
else
{
if (UseFastSwipe && distance < panelDimensions.height + FastSwipeThreshold && distance >=1f)
{
_scroll_rect.velocity = Vector3.zero;
if (_startPosition.y - _screensContainer.localPosition.y > 0)
{
if (_startPosition.y - _screensContainer.localPosition.y > _childSize / 3)
{
ScrollToClosestElement();
}
else
{
NextScreen();
}
}
else
{
if (_startPosition.y - _screensContainer.localPosition.y > -_childSize / 3)
{
ScrollToClosestElement();
}
else
{
PreviousScreen();
}
}
}
} }
} }
} }