Author Topic: UIScrollView bug?  (Read 1572 times)

DirtyHippy

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 25
    • View Profile
UIScrollView bug?
« on: January 17, 2014, 02:23:56 PM »
Note: 3.0.8 F6 (posting because I don't see the fix in the F7 release notes).

Shouldn't the line below:

         if (movement == Movement.Horizontal || movement == Movement.Unrestricted)

be:

         if (movement == Movement.Horizontal)

as otherwise if you have movement == Unrestricted and custommovement = {0,1} it will scroll horizontally instead of vertically (because the code then is "new Vector3(mScroll * 0.05f, 0f, 0f));" which scrolls in X even if custom movement is along the Y.


This certainly fixed the problem I was having.

  1.                 // Apply momentum
  2.                 if (mShouldMove && !mPressed)
  3.                 {
  4.                         if (movement == Movement.Horizontal || movement == Movement.Unrestricted)
  5.                         {
  6.                                 mMomentum -= mTrans.TransformDirection(new Vector3(mScroll * 0.05f, 0f, 0f));
  7.                         }
  8.                         else if (movement == Movement.Vertical)
  9.                         {
  10.                                 mMomentum -= mTrans.TransformDirection(new Vector3(0f, mScroll * 0.05f, 0f));
  11.                         }
  12.                         else
  13.                         {
  14.                                 mMomentum -= mTrans.TransformDirection(new Vector3(
  15.                                         mScroll * customMovement.x * 0.05f,
  16.                                         mScroll * customMovement.y * 0.05f, 0f));
  17.                         }
  18.  

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIScrollView bug?
« Reply #1 on: January 17, 2014, 02:32:20 PM »
It should probably be:
  1.                         if (movement == Movement.Horizontal)
  2.                         {
  3.                                 mMomentum -= mTrans.TransformDirection(new Vector3(mScroll * 0.05f, 0f, 0f));
  4.                         }
  5.                         else if (movement == Movement.Vertical)
  6.                         {
  7.                                 mMomentum -= mTrans.TransformDirection(new Vector3(0f, mScroll * 0.05f, 0f));
  8.                         }
  9.                         else if (movement == Movement.Unrestricted)
  10.                         {
  11.                                 mMomentum -= mTrans.TransformDirection(new Vector3(mScroll * 0.05f, mScroll * 0.05f, 0f));
  12.                         }
  13.                         else
  14.                         {
  15.                                 mMomentum -= mTrans.TransformDirection(new Vector3(
  16.                                         mScroll * customMovement.x * 0.05f,
  17.                                         mScroll * customMovement.y * 0.05f, 0f));
  18.                         }