From c8de1b928992df29cb345528bb55f0c6eefce36e Mon Sep 17 00:00:00 2001 From: Johannes Deml Date: Wed, 2 Aug 2017 11:57:02 +0200 Subject: [PATCH 1/3] FIX fastswipe threshold Does now what is stated it does in the tooltip: Offset for how far a swipe has to travel to initiate a page change (optional) --- Scripts/Layout/HorizontalScrollSnap.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Scripts/Layout/HorizontalScrollSnap.cs b/Scripts/Layout/HorizontalScrollSnap.cs index 3fe3cfe..f3c01a0 100644 --- a/Scripts/Layout/HorizontalScrollSnap.cs +++ b/Scripts/Layout/HorizontalScrollSnap.cs @@ -236,7 +236,7 @@ namespace UnityEngine.UI.Extensions if (_scroll_rect.horizontal) { var distance = Vector3.Distance(_startPosition, _screensContainer.localPosition); - if (UseFastSwipe && distance < panelDimensions.width + FastSwipeThreshold && distance >=1f) + if (UseFastSwipe && distance < panelDimensions.width && distance >= FastSwipeThreshold) { _scroll_rect.velocity = Vector3.zero; if (_startPosition.x - _screensContainer.localPosition.x > 0) From 14f42df81c00f3d6c4aca5f254f0a6ffb1f2d160 Mon Sep 17 00:00:00 2001 From: Johannes Deml Date: Wed, 2 Aug 2017 11:59:27 +0200 Subject: [PATCH 2/3] REFACTOR make method more readable --- Scripts/Layout/HorizontalScrollSnap.cs | 2 +- Scripts/Layout/ScrollSnapBase.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Scripts/Layout/HorizontalScrollSnap.cs b/Scripts/Layout/HorizontalScrollSnap.cs index f3c01a0..fa532c2 100644 --- a/Scripts/Layout/HorizontalScrollSnap.cs +++ b/Scripts/Layout/HorizontalScrollSnap.cs @@ -250,6 +250,6 @@ namespace UnityEngine.UI.Extensions } } } - #endregion + #endregion } } \ No newline at end of file diff --git a/Scripts/Layout/ScrollSnapBase.cs b/Scripts/Layout/ScrollSnapBase.cs index b7aea59..c07771f 100644 --- a/Scripts/Layout/ScrollSnapBase.cs +++ b/Scripts/Layout/ScrollSnapBase.cs @@ -314,8 +314,8 @@ namespace UnityEngine.UI.Extensions internal int GetPageforPosition(Vector3 pos) { return _isVertical ? - -(int)Math.Round((pos.y - _scrollStartPosition) / _childSize) : - -(int)Math.Round((pos.x - _scrollStartPosition) / _childSize); + (int)Math.Round((_scrollStartPosition - pos.y) / _childSize) : + (int)Math.Round((_scrollStartPosition - pos.x) / _childSize); } /// From 2c8550532d2f0c7d8fa0636d1b21bb7c1dd99a1d Mon Sep 17 00:00:00 2001 From: Johannes Deml Date: Wed, 2 Aug 2017 12:28:09 +0200 Subject: [PATCH 3/3] CHANGE tooltip to describe the actual (changed) behaviour --- Scripts/Layout/ScrollSnapBase.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Scripts/Layout/ScrollSnapBase.cs b/Scripts/Layout/ScrollSnapBase.cs index c07771f..44867e3 100644 --- a/Scripts/Layout/ScrollSnapBase.cs +++ b/Scripts/Layout/ScrollSnapBase.cs @@ -64,7 +64,7 @@ namespace UnityEngine.UI.Extensions [Tooltip("Fast Swipe makes swiping page next / previous (optional)")] public Boolean UseFastSwipe = false; - [Tooltip("Offset for how far a swipe has to travel to initiate a page change (optional)\nDefault is the panel dimensions")] + [Tooltip("Offset for how far a swipe has to travel to initiate a page change (optional)")] public int FastSwipeThreshold = 100; [Tooltip("Speed at which the ScrollRect will keep scrolling before slowing down and stopping (optional)")]