Refactored HSS/VSS to move the onEndDrag interface bindings are on the BaseScrollSnap instead of the child controls

pull/413/head
Simon (darkside) Jackson 2020-05-22 12:15:58 +01:00
parent 84c030278b
commit 018bb1c524
3 changed files with 8 additions and 11 deletions

View File

@ -10,7 +10,7 @@ namespace UnityEngine.UI.Extensions
[RequireComponent(typeof(ScrollRect))]
[AddComponentMenu("Layout/Extensions/Horizontal Scroll Snap")]
public class HorizontalScrollSnap : ScrollSnapBase, IEndDragHandler
public class HorizontalScrollSnap : ScrollSnapBase
{
void Start()
{
@ -235,13 +235,11 @@ namespace UnityEngine.UI.Extensions
GoToScreen(StartingScreen);
}
#region Interfaces
/// <summary>
/// Release screen to swipe
/// </summary>
/// <param name="eventData"></param>
public void OnEndDrag(PointerEventData eventData)
public override void OnEndDrag(PointerEventData eventData)
{
_pointerDown = false;
@ -307,7 +305,5 @@ namespace UnityEngine.UI.Extensions
}
}
}
#endregion
}
}

View File

@ -8,7 +8,7 @@ using UnityEngine.EventSystems;
namespace UnityEngine.UI.Extensions
{
public class ScrollSnapBase : MonoBehaviour, IBeginDragHandler, IDragHandler, IScrollSnap
public class ScrollSnapBase : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler, IScrollSnap
{
internal Rect panelDimensions;
internal RectTransform _screensContainer;
@ -582,6 +582,8 @@ namespace UnityEngine.UI.Extensions
_lerp = false;
}
public virtual void OnEndDrag(PointerEventData eventData) { }
#endregion
#region IScrollSnap Interface
@ -609,6 +611,7 @@ namespace UnityEngine.UI.Extensions
{
GoToScreen(page);
}
#endregion
}
}

View File

@ -10,7 +10,7 @@ namespace UnityEngine.UI.Extensions
{
[RequireComponent(typeof(ScrollRect))]
[AddComponentMenu("Layout/Extensions/Vertical Scroll Snap")]
public class VerticalScrollSnap : ScrollSnapBase, IEndDragHandler
public class VerticalScrollSnap : ScrollSnapBase
{
void Start()
{
@ -228,12 +228,11 @@ namespace UnityEngine.UI.Extensions
if(RestartOnEnable) GoToScreen(StartingScreen);
}
#region Interfaces
/// <summary>
/// Release screen to swipe
/// </summary>
/// <param name="eventData"></param>
public void OnEndDrag(PointerEventData eventData)
public override void OnEndDrag(PointerEventData eventData)
{
_pointerDown = false;
@ -298,6 +297,5 @@ namespace UnityEngine.UI.Extensions
}
}
}
#endregion
}
}