Author Topic: Little polish on UIScrollView  (Read 2620 times)

Grhyll

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 32
    • View Profile
Little polish on UIScrollView
« on: June 05, 2014, 10:26:41 AM »
Hi,

Just to submit a little polish proposition on UIScrollView, that I've just done myself for my needs; in case Momentum is chosen (with unrestricted movements), I think the scroll view should not stop immediately if the bound is met in one of the direction ; it should continue in the direction which still has space to move.

I did it very simply in RestrictWithinBounds with:

  1. if(Mathf.Abs(constraint.x) > 1f)
  2.         mMomentum.x = 0;
  3. if(Mathf.Abs(constraint.y) > 1f)
  4.         mMomentum.y = 0;
  5. if(Mathf.Abs(constraint.z) > 1f)
  6.         mMomentum.z = 0;

Instead of

  1. mMomentum = Vector3.zero;

I guess it's not totally clean, but it seems to work.

Another suggestion for MomentumAndSpring would be to allow the user to select the strenght of the force that prevent the user to drag the view too far from the bound (which is currently determined by a hard coded 0.5f).

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Little polish on UIScrollView
« Reply #1 on: June 06, 2014, 02:18:57 AM »
The first suggestion seems valid. The second one... I'd say modify the script if you need that level of control. I haven't heard this suggestion yet, so I am guessing most people don't.