void Update() { if (content.anchoredPosition.x > pullRefleshLength && pullRefleshing == PullRefleshType.None && !isTouching && scrollRect.IsDrag) { pullRefleshing = PullRefleshType.PullRight; if (OnPullRightReflesh != null) { OnPullRightReflesh(); } isTouching = true; } else if (content.sizeDelta.x > scrollView.rect.width && content.anchoredPosition.x + content.sizeDelta.x - scrollView.rect.width < -pullRefleshLength && pullRefleshing == PullRefleshType.None && !isTouching && scrollRect.IsDrag) { pullRefleshing = PullRefleshType.PullLeft; if (OnPullLeftReflesh != null) { OnPullLeftReflesh(); } isTouching = true; } if (isTouching && !scrollRect.IsDrag) { isTouching = false; } }
// Update is called once per frame void OnEnable() { pullRefleshing = PullRefleshType.None; canPullRefresh = true; scrollRect.enabled = true; if (loadingSpinner != null) { loadingSpinner.SetActive(false); } }
public void PullRefleshCompleted() { if(this.gameObject.activeInHierarchy) { StartCoroutine(WaitTouchRelease()); } else { pullRefleshing = PullRefleshType.None; scrollRect.enabled = true; if (loadingSpinner != null) { loadingSpinner.SetActive(false); } canPullRefresh = true; } }
public void PullRefleshCompleted(bool pinned = false) { pullRefleshing = PullRefleshType.None; }
void Update() { if (content.anchoredPosition.y < -pullRefleshThreshold && pullRefleshing == PullRefleshType.None && canPullRefresh) { pullRefleshing = PullRefleshType.PullDown; canPullRefresh = false; if (OnPullDownReflesh != null) { if (loadingSpinner != null) { loadingSpinner.SetActive(true); } OnPullDownReflesh(); } } }
IEnumerator WaitTouchRelease() { pullRefleshing = PullRefleshType.None; scrollRect.enabled = true; if (loadingSpinner != null) { loadingSpinner.SetActive(false); } while (Input.touchCount > 0 || Input.GetMouseButton(0)) yield return 1; yield return new WaitForSeconds(pullRefleshWaitInterval); canPullRefresh = true; }