|
Post by nolkeg on Jun 27, 2020 18:33:17 GMT
So, the scroll position is never going below 0 which cause threshold to not work. Is there a work around for this? I really need threshold since I don't want users to accidentally refresh data by their random stray drag.
|
|
|
Post by echo17 on Jun 29, 2020 12:22:49 GMT
Let me take a look...
|
|
|
Post by echo17 on Jun 29, 2020 12:58:37 GMT
OK, I've got a fix for this. Instead of the scroll position which you point out was always clamped to zero, you can use the ScrollRect's content anchoredPosition. I've submitted an update to the Asset Store (2.25.1) to fix this, but if you want to just copy the following code to replace the ScrollerScrolled method of the Demo #11 controller, that will fix it too:
private void ScrollerScrolled(EnhancedScroller scroller, Vector2 val, float scrollPosition) { var scrollMoved = (scroller.ScrollRect.content.anchoredPosition.y <= -pullDownThreshold);
if (_dragging && scrollMoved) { // we are dragging and the scroll position is beyond the scroll threshold. // we should flag that a refresh is needed when the dragging is released. _pullToRefresh = true;
// show the release text if the scroller is down beyond the threshold releaseToRefreshText.gameObject.SetActive(true); }
// show the pull to refresh text if the scroller position is at the top pullDownToRefreshText.gameObject.SetActive(scrollPosition <= 0); }
Thanks for pointing this out!
|
|
|
Post by nolkeg on Jun 29, 2020 16:09:12 GMT
Thanks. I also have another question, is there a way to get the current scroller position and cell offset? I want to jump to the user last frame position but I don't know how to calculate those two value
|
|
|
Post by echo17 on Jun 30, 2020 13:01:40 GMT
The current scroll position can be found using the property ScrollPosition. The offset would depend on which cell you are trying to locate. You can get any cell view position by calling GetScrollPositionForDataIndex. This will return the upper position if the scroller is vertical or leftmost if the scroller is horizontal.
I think I'd need to see an example project, illustration, or video that demonstrates what you are wanting to achieve for me to give you more exact advice.
|
|