Scrolling issue - scrollbar jumps

So I just converted my app to the latest daily build and using graphics compatibility mode.

Got my scrollView positioning all set, but noticing an issue with scrolling.  It scrolls fine, but as it gets to the bottom, the scroll bar just jumps to the bottom.  And when its at the end, if I slowly start to scroll up, the scroll bar jumps up about a quarter of the way.  Not sure why it is doing that.

I don’t have a scrollWidth or scrollHeight set, so I tried setting them as the same width and height as the scrollView, then when i do my dynamic building of the text that I put it in the scrollView, I look at the Y position of the last item I put in there and did a setScrollHeight with that value.  It then scrolls properly and smoothly, but doesn’t go all the way to the end.  Not sure why that it is, since I am using the position of the last item.

I tried just adding amounts to the value and it got to where it should be, but again, it is doing the jumping at the bottom.  If I set it to a value larger, than it extends past the “end” of my content and scrolls without jumping.  Weird.

Not sure what might be causing this and how to look at tackling it.

Any thoughts?

Well you should be setting scrollHeight and scrollWidth (if you scroll horizontally also) and you were on the right track by setting it to your content height. If you set it too small then the scroll bar doesn’t know where to go when you scroll past your scrollHeight. Setting it bigger is not a problem but will let you scroll past your content. So you should set it to the bottom of your last item plus a margin if you need it. Remember that y position of your last item is probably not it’s bottom unless you are using bottom reference point. So add it’s height to y for top reference point or half of height for center.

In G2 scrollView is supposed to update it’s scrollHeight based on items inserted but I’m not sure how this works in compatibility mode.

@primoz.cerar,

Thanks for the information.  But it doesn’t quite work that way.  I saw another thread about how setScrollHeight and setScrollWidth don’t actually work.

If I don’t set a scrollHeight, scrolling works fine and I can scroll to the end of the content but the scrollbar jumps at the end, and when I go to scroll back up.

If I set scrollHeight to the Y position of the last element inserted into the scrollView (and I add 5, even though the element i just 1 unit tall), it does not scroll to the end of the content, but stops before.  It does scroll without jumping, however.

If I set scrollHeight to the Y position of the last element inserted into the scrollView (and add about 300, what I estimated it to be to the end of the content), it does scroll to the end of the content but the scrollbar jumps like it does when I don’t set a scrollHeight.

If I set the scrollHeight to the Y position of the last element inserted into the scrollView (and add a much larger number, like 700), it scrolls past the end of the content, with no jumping scrollbar.

Doesn’t really make sense to me at all.

my scrollbar jumps also a little bit up and down, really weird

It is like it doesn’t know the actual height of the content inside.  This is more evident since as I dynamically add things, I am keeping track of the height of the content that is going in to position it, but when I use that value as a scrollHeight, it doesn’t go to the end.

Without specifying a scrollHeight and letting the auto calculation to take place, if I scroll to the bottom of my scrollView, then just tap in the scrollView (but not move or scroll, just tap), the scrollbar jumps up.

Hi @thegdog,

Can you assemble a simple project that shows this in action? We can investigate it much easier that way.

Thanks,

Brent

Brent,

I logged a bug with sample code.

It is Case 30464: scrollView issues: scrollbar jumps, scrollbar cut off at top, scrollBarAutoHide = false does not work reliably

Tried to reduce this to the simplest code I could from mine.  Hope it is simple enough.

Well you should be setting scrollHeight and scrollWidth (if you scroll horizontally also) and you were on the right track by setting it to your content height. If you set it too small then the scroll bar doesn’t know where to go when you scroll past your scrollHeight. Setting it bigger is not a problem but will let you scroll past your content. So you should set it to the bottom of your last item plus a margin if you need it. Remember that y position of your last item is probably not it’s bottom unless you are using bottom reference point. So add it’s height to y for top reference point or half of height for center.

In G2 scrollView is supposed to update it’s scrollHeight based on items inserted but I’m not sure how this works in compatibility mode.

@primoz.cerar,

Thanks for the information.  But it doesn’t quite work that way.  I saw another thread about how setScrollHeight and setScrollWidth don’t actually work.

If I don’t set a scrollHeight, scrolling works fine and I can scroll to the end of the content but the scrollbar jumps at the end, and when I go to scroll back up.

If I set scrollHeight to the Y position of the last element inserted into the scrollView (and I add 5, even though the element i just 1 unit tall), it does not scroll to the end of the content, but stops before.  It does scroll without jumping, however.

If I set scrollHeight to the Y position of the last element inserted into the scrollView (and add about 300, what I estimated it to be to the end of the content), it does scroll to the end of the content but the scrollbar jumps like it does when I don’t set a scrollHeight.

If I set the scrollHeight to the Y position of the last element inserted into the scrollView (and add a much larger number, like 700), it scrolls past the end of the content, with no jumping scrollbar.

Doesn’t really make sense to me at all.

my scrollbar jumps also a little bit up and down, really weird

It is like it doesn’t know the actual height of the content inside.  This is more evident since as I dynamically add things, I am keeping track of the height of the content that is going in to position it, but when I use that value as a scrollHeight, it doesn’t go to the end.

Without specifying a scrollHeight and letting the auto calculation to take place, if I scroll to the bottom of my scrollView, then just tap in the scrollView (but not move or scroll, just tap), the scrollbar jumps up.

Hi @thegdog,

Can you assemble a simple project that shows this in action? We can investigate it much easier that way.

Thanks,

Brent

Brent,

I logged a bug with sample code.

It is Case 30464: scrollView issues: scrollbar jumps, scrollbar cut off at top, scrollBarAutoHide = false does not work reliably

Tried to reduce this to the simplest code I could from mine.  Hope it is simple enough.