Author Topic: UIScrollView contents not springing back / staying within panel if anchors moved  (Read 4442 times)

AssyriaGameStudio

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 11
    • View Profile
Hey,
So I've got a scroll view with some content inside. Sometimes the content doesn't fill the full height of the scrollview, however I need it to still be draggable (as I have it then updating content on pull-down in a similar way to the facebook app etc). So I'm re-sizing the scrollview to the size/height of the content in instances where the content is smaller than the height.

The issue is that once the lower-anchor has been moved to reduce the height down to the size of the content, the position at which the "Spring Panel" kicks in appears to not be updated.

This video highlights the issue in a way that's likely clearer than my (admittedly shit) attempt at an explanation: https://www.dropbox.com/s/3hlo04c9zezfp73/scrollview_spring_not_updating.m4v?dl=0

You'll notice when the content over-flows it all bounces back fine, but when the content is smaller than the scroll view and I adjust the scrollviews anchor to suit, I can drag the content below the lower bound of the scroll view and it doesn't bounce back.

I've tried forcing updates / resets on everything I can think of to no avail (as seen at the end of the clip). So really I could just use some guidance as to how to go about getting the Spring Panel trigger to also be updated to suit the new scrollview anchors?

Many thanks!
« Last Edit: March 09, 2016, 04:49:41 PM by AssyriaGameStudio »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
NGUI has an option on the scroll view "stop dragging if fits" or something like that. If you uncheck it, you will be able to drag the content even if it's smaller than your scroll view -- no resizing necessary. In the case of anchors, if you have some complex setup where you have moving anchors inside a scroll view that change the size of the content, you will need to update the scroll view's bounds manually by calling InvalidateBounds() on it. The scroll view doesn't track the size of the content in real time, it would be a waste of performance if it did.

AssyriaGameStudio

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 11
    • View Profile
Hey, as mentioned; I need it to be draggable (even if it fits) as I have a pull-down-to-refresh style system in place as mentioned in the initial post.

Additionally I've tried calling InvalidateBounds (See the end of the video where I have tried InvaliteBounds and lots of other things) and it's not working / it doesn't appear to be actually updating the bounds.

(The "UpdateScrollerSize" function is called immediately after new content is put into the ScrollView.)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Unchecking that checkbox will make it draggable even if it fits.

AssyriaGameStudio

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 11
    • View Profile
Unchecking that checkbox will make it draggable even if it fits.

It already is unchecked (see the video), it's dragging fine. The issue is that it's just not Springing Back to the right place when it exceeds the lower bound (when the lower bound is moved / despite the bound being invalidated).

Video Link: https://www.dropbox.com/s/3hlo04c9zezfp73/scrollview_spring_not_updating.m4v?dl=0

To clarify what I mean:
- In the video I pull down a list between 0:02-0:04 seconds in.
- I switch to the "Education" list (in which the scrollviews contents wouldn't fill the full scroll view area).
- The scroll bar's lower bounds have moved as is shown in the scene view to compensate for this.
- The bounds have been invalidated (viewable at the end of the video in script).
- At 0:09 I try pull the content of the scroller below the lower bound of the UIScrollView.
- It doesn't bounce back.
- Notice it does bounce back then it exceeds the upper bound (as this bound hasn't moved).
- Despite "InvalidateBounds" being called, the SpringPosition component isn't being re-enabled / triggered at the correct point when the contents exceeds the lower bound.
« Last Edit: March 13, 2016, 12:30:14 PM by AssyriaGameStudio »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Ok... So you want the scroll view to spring to the top at the 0:09 mark? Looking at the video, I don't see your content actually being clipped at all. My first guess would be that the scroll view's panel differs from whatever you are adjusting. You do have a few pink borders there... You're also not calling UIScrollView's RestrictWithinBounds() function anywhere, so I assume you're relying on it to be called when the user drags the content? If you can't get it to work, you can always submit a repro case for me to look at btw -- support [at] tasharen.com.