31 lines
1.0 KiB
C#
31 lines
1.0 KiB
C#
|
|
using UnityEngine;
|
|||
|
|
using UnityEngine.EventSystems;
|
|||
|
|
using Kill.UI.Pages;
|
|||
|
|
|
|||
|
|
namespace Kill.UI.Components
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// 下拉刷新触发器:挂到主页 ScrollRect(带 Image 的 Graphic)上,接收 EventSystem
|
|||
|
|
/// 拖拽事件并转发给 HomePageCtrl。这样在滚动区域内任意位置都可触发下拉刷新。
|
|||
|
|
/// </summary>
|
|||
|
|
public class HomePagePullRefreshTrigger : MonoBehaviour, IBeginDragHandler, IDragHandler, IEndDragHandler
|
|||
|
|
{
|
|||
|
|
public void OnBeginDrag(PointerEventData eventData)
|
|||
|
|
{
|
|||
|
|
var ctrl = HomePageCtrl.Instance;
|
|||
|
|
if (ctrl != null) ctrl.OnPullRefreshBeginDrag();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void OnDrag(PointerEventData eventData)
|
|||
|
|
{
|
|||
|
|
var ctrl = HomePageCtrl.Instance;
|
|||
|
|
if (ctrl != null) ctrl.OnPullRefreshDrag(eventData.delta.y);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void OnEndDrag(PointerEventData eventData)
|
|||
|
|
{
|
|||
|
|
var ctrl = HomePageCtrl.Instance;
|
|||
|
|
if (ctrl != null) ctrl.OnPullRefreshEndDrag();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|