modify
This commit is contained in:
parent
1f7b111a23
commit
6af2f7c370
@ -114,6 +114,7 @@ namespace AlicizaX.UI.RecyclerView
|
|||||||
private int currentIndex;
|
private int currentIndex;
|
||||||
|
|
||||||
public Scroller Scroller => _scroller;
|
public Scroller Scroller => _scroller;
|
||||||
|
|
||||||
public int CurrentIndex
|
public int CurrentIndex
|
||||||
{
|
{
|
||||||
get => currentIndex;
|
get => currentIndex;
|
||||||
@ -140,6 +141,7 @@ namespace AlicizaX.UI.RecyclerView
|
|||||||
|
|
||||||
public Action<int> OnIndexChanged;
|
public Action<int> OnIndexChanged;
|
||||||
public Action OnScrollValueChanged;
|
public Action OnScrollValueChanged;
|
||||||
|
public Action OnMoveingChanged;
|
||||||
|
|
||||||
private void OnValidate()
|
private void OnValidate()
|
||||||
{
|
{
|
||||||
@ -206,6 +208,11 @@ namespace AlicizaX.UI.RecyclerView
|
|||||||
OnScrollValueChanged?.Invoke();
|
OnScrollValueChanged?.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnMoveing()
|
||||||
|
{
|
||||||
|
OnMoveingChanged?.Invoke();
|
||||||
|
}
|
||||||
|
|
||||||
private void OnMoveStoped()
|
private void OnMoveStoped()
|
||||||
{
|
{
|
||||||
if (Snap)
|
if (Snap)
|
||||||
@ -286,6 +293,7 @@ namespace AlicizaX.UI.RecyclerView
|
|||||||
_scroller.Snap = Snap;
|
_scroller.Snap = Snap;
|
||||||
_scroller.OnValueChanged.AddListener(OnScrollChanged);
|
_scroller.OnValueChanged.AddListener(OnScrollChanged);
|
||||||
_scroller.OnMoveStoped.AddListener(OnMoveStoped);
|
_scroller.OnMoveStoped.AddListener(OnMoveStoped);
|
||||||
|
_scroller.OnMoveing.AddListener(OnMoveing);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,19 @@ namespace AlicizaX.UI.RecyclerView
|
|||||||
void ScrollTo(float position, bool smooth = false);
|
void ScrollTo(float position, bool smooth = false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ScrollerEvent : UnityEvent<float> { }
|
public class ScrollerEvent : UnityEvent<float>
|
||||||
public class MoveStopEvent : UnityEvent { }
|
{
|
||||||
public class DraggingEvent : UnityEvent<bool> { }
|
}
|
||||||
|
|
||||||
|
public class MoveStopEvent : UnityEvent
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public class DraggingEvent : UnityEvent<bool>
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public class MoveingEvent : UnityEvent
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,11 +76,18 @@ namespace AlicizaX.UI.RecyclerView
|
|||||||
protected ScrollerEvent scrollerEvent = new();
|
protected ScrollerEvent scrollerEvent = new();
|
||||||
protected MoveStopEvent moveStopEvent = new();
|
protected MoveStopEvent moveStopEvent = new();
|
||||||
protected DraggingEvent draggingEvent = new();
|
protected DraggingEvent draggingEvent = new();
|
||||||
|
protected MoveingEvent moveingEvent = new();
|
||||||
|
|
||||||
public float MaxPosition => direction == Direction.Vertical ? Mathf.Max(contentSize.y - viewSize.y, 0) : Mathf.Max(contentSize.x - viewSize.x, 0);
|
public float MaxPosition => direction == Direction.Vertical ? Mathf.Max(contentSize.y - viewSize.y, 0) : Mathf.Max(contentSize.x - viewSize.x, 0);
|
||||||
|
|
||||||
public float ViewLength => direction == Direction.Vertical ? viewSize.y : viewSize.x;
|
public float ViewLength => direction == Direction.Vertical ? viewSize.y : viewSize.x;
|
||||||
|
|
||||||
|
public MoveingEvent OnMoveing
|
||||||
|
{
|
||||||
|
get => moveingEvent;
|
||||||
|
set => moveingEvent = value;
|
||||||
|
}
|
||||||
|
|
||||||
public ScrollerEvent OnValueChanged
|
public ScrollerEvent OnValueChanged
|
||||||
{
|
{
|
||||||
get => scrollerEvent;
|
get => scrollerEvent;
|
||||||
@ -144,6 +151,7 @@ namespace AlicizaX.UI.RecyclerView
|
|||||||
position += velocity;
|
position += velocity;
|
||||||
|
|
||||||
OnValueChanged?.Invoke(position);
|
OnValueChanged?.Invoke(position);
|
||||||
|
OnMoveing?.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void OnScrolled(PointerEventData eventData)
|
public virtual void OnScrolled(PointerEventData eventData)
|
||||||
@ -155,7 +163,7 @@ namespace AlicizaX.UI.RecyclerView
|
|||||||
position += velocity;
|
position += velocity;
|
||||||
|
|
||||||
OnValueChanged?.Invoke(position);
|
OnValueChanged?.Invoke(position);
|
||||||
|
OnMoveing?.Invoke();
|
||||||
Elastic();
|
Elastic();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user