|
Post by meneleus on Apr 14, 2021 14:38:04 GMT
I just verified that version: 2.25.0 works perfectly. (I don't have older releases in between.)
The latest version however, does not give me the last position of the Tween.
I use the following code:
scroller.scrollerScrolled = (EnhancedScroller scroller, Vector2 val, float scrollPosition) => { Debug.LogFormat("scrollerScrolled({0}, {1}, {2})", val, scrollPosition, scroller.StartDataIndex); currentOffset = scroller.StartCellViewIndex; UpdateButtons(); }; The UpdateButtons() method uses the currentOffset to calculate where we are in the scroll (for a pager) and whether the back and forward buttons should be enabled.
With the new version scroller.StartCellViewIndex and scroller.StartDataIndex are not correct at the end of the Tween.
I initiate the scroll with:
scroller.JumpToDataIndex(newOffset, 0, 0, false, EnhancedScroller.TweenType.easeInCubic, 0.5f, () => { Debug.LogFormat("JumpToDataIndex.Complete({0}, {1})", scroller.StartDataIndex, scroller.StartCellViewIndex); });
The logs look like this:
ScrollTo(0) scrollerScrolled((1.0, 0.0), 11569.75, 108) scrollerScrolled((1.0, 0.0), 11568.9, 108) ... scrollerScrolled((1.0, 0.0), 11306.92, 106) ... scrollerScrolled((0.2, 0.0), 1776.096, 41) ... JumpToDataIndex.Complete(16, 16) ... scrollerScrolled((0.0, 0.0), 0, 16) Which is showing that I'm getting a Complete at the wrong location and then getting a Scrolled after that.
Any clues?
|
|
|
Post by meneleus on Apr 14, 2021 15:13:24 GMT
I tracked down the bug to this change:
- _RefreshActive(); + // deprecated: it appears calling this at the end can cause the wrong cell range to be calculated + //_RefreshActive();
If I put back the _RefreshActive(); my code works again.
There is a separate issue where I never get to the last page in my pager because it's not a full page. I needed to ceil the ScrollSize to make that work (this was broken for me in the old version too)
public float ScrollSize { get { if (scrollDirection == ScrollDirectionEnum.Vertical) return Mathf.Ceil(Mathf.Max(_container.rect.height - _scrollRectTransform.rect.height, 0)); else return Mathf.Ceil(Mathf.Max(_container.rect.width - _scrollRectTransform.rect.width, 0)); } }
|
|
|
Post by echo17 on Apr 14, 2021 17:12:47 GMT
If you could send me an example project demonstrating the two issues, along with steps to reproduce, I can take a look and make sure any changes I make don't undo any other fixes in place. Please see this FAQ for more information: link
|
|