andre
New Member
Posts: 3
|
Post by andre on Aug 6, 2019 14:16:52 GMT
Hi, we are currently implementing a „Pull To Refresh” Option in our lists. According to your Examples we need to check the “scrollPosition” value to be negative in the “scrollerScrolled” Event. However, it does not return a negative value due to line 1753 in EnhancedScroller.cs, e.g. _ScrollRect_OnValueChanged(Vector2 val): _scrollPosition = Mathf.Clamp(_scrollPosition, 0, GetScrollPositionForCellViewIndex(_cellViewSizeArray.Count - 1, CellViewPositionEnum.Before)); We think, if you clamp the value to -999 or the like, it would work correctly (maybe only if not using a Looping Listview?)?
Can you please also take a look, that the scrollPosition will be correctly returned if <= 1 items are visible in the list. Currently it looks like, that this is not working (returns always 0).
What do you think?
p.s.: We wrote you two emails, 25 and 24 july but did not get an answer, maybe it is in the Spam-Folder?
Thank you.
Regards André
|
|
|
Post by echo17 on Aug 7, 2019 13:03:38 GMT
I am so sorry about the email, that must have been frustrating to not get a reply. I checked my spam folder and your two emails were there. I have disabled my spam block so hopefully I should get any future correspondence from you.
I just tested the example pull down refresh demo and it appears to be working for me. Based on what you described, it sounds like you might have an older version of the plugin. In the current one, the controller code has the following line in the ScrollerScrolled method:
var scrollMoved = ((scrollPosition <= -pullDownThreshold) || scrollPosition == 0);
You can see that it is checking for negative or zero position to determine if it needs to refresh. Testing with 100 or 1 elements in the list both works fine. I also tested with looping and that worked as well.
I would recommend upgrading to the latest version of EnhancedScroller (2.21.1) or copying the above line into your ScrollerScrolled method. The full method looks like:
private void ScrollerScrolled(EnhancedScroller scroller, Vector2 val, float scrollPosition) { var scrollMoved = ((scrollPosition <= -pullDownThreshold) || scrollPosition == 0);
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); }
|
|
andre
New Member
Posts: 3
|
Post by andre on Aug 7, 2019 14:23:20 GMT
Thank you very much. For the Spam stuff and for the update notice. I will check for the update and let you know!
|
|
andre
New Member
Posts: 3
|
Post by andre on Aug 7, 2019 23:59:30 GMT
I have checked this now, but we have the newest code. We would like to realize a "pull-down" feature for the list. If the user pulls down enought, we can refresh the view. Our scroller looks like this:
private void ScrollerScrolled(EnhancedScroller scroller, Vector2 val, float scrollPosition) { float step = Mathf.Clamp(Mathf.Abs(scrollPosition) / pullDownThreshold, 0.0f, 1.0f); pullDownToRefreshIcon.SetGameObjectActive(step > 0.01f);
if (scrollPosition < 0.0f) { pullDownToRefreshIcon.SetAnimationStep(step); m_pullToRefresh = ((step >= 1.0f) && (m_dragging)); } }
This works as expected, but only if we have more then one item, and Modifiying EnhancedScroller.cs, line 1753, to allow negative values:
_scrollPosition = Mathf.Clamp(_scrollPosition, -999.0f, GetScrollPositionForCellViewIndex(_cellViewSizeArray.Count - 1, CellViewPositionEnum.Before));
Can you help us, that the pull down will also work, even if we have just one item?
|
|
|
Post by echo17 on Aug 8, 2019 13:03:37 GMT
I'm sorry, I am not able to get any problems using the included demo #11. It works with one or many items. Try recreating your code based on that demo first and you might discover what the difference is in your script.
|
|
|
Post by masegi on Oct 22, 2019 22:01:15 GMT
Hi,
I have a similar project.
What pullDownThreshold did you use? And how did you managed to get the scrollPosition? When I try to access it, it's always 0.
[edit] oh ok it only shows scrollPosition when there are enough items in the list!? [/edit]
|
|
|
Post by echo17 on Oct 23, 2019 11:04:20 GMT
Correct, it always shows scrollPosition, but if you have fewer items than the size of the scrolling area, the scrollPosition will always be zero. The scrollPosition is the offset of the scroll container from the ScrollRect parent. If there are not enough items to scroll, the scroll container will be smaller than the parent and never offset. This is true of Unity's base ScrollRect functionality and not a separate part of EndlessScroller.
|
|