Author Topic: UIScrollView/UIDragScrollView keep from dragging past first/last item in list  (Read 5182 times)

nguiman

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 30
    • View Profile
I have a scrollview and the elements are draggable within it.

How do I lock it so the first element can't be dragged further inside than the top or the last element can't be dragged further inside than the bottom? Like a standard scrollable list you'd find on a website.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Drag Effect: None.

nguiman

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 30
    • View Profile
Thanks, thats close to what I want. But I find there's still a bit of a spring/settle when moving the elements, I notice there's a 'SpringPanel' being added to the scollview, how do I disable it? UIScrollView.DisableSpring didn't appear to work. Or would I need to do something else?

Also anyway to make this work with UICenterOnClick?
« Last Edit: May 01, 2014, 12:29:46 AM by nguiman »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
How can you center on the top-most element if your content is limited to the top of the panel?

nguiman

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 30
    • View Profile
Yeah I imagine there might need to be some special casing for the start and end.

But is there anyway to prevent the slight spring/settle on the list?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Slight spring/settle? Looking at it I see there is a 1 pixel stutter going on, is this what you mean? That can be fixed by modifying line 368 of UIScrollView.cs from this:
  1. if (constraint.sqrMagnitude > 1f)
to this:
  1. if (constraint.sqrMagnitude > 0.1f)

nguiman

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 30
    • View Profile
Thanks! I think it has something to do with the UICenterOnChild as well.