Author Topic: Scrollview Offset Inaccurate  (Read 3156 times)

cruncher3019

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 2
    • View Profile
Scrollview Offset Inaccurate
« on: December 22, 2014, 12:06:15 PM »
Hey guys, I couldn't find an answer to my issue so I'm making a thread for it here.

I have certain functionality that's depending on whether or not the scroll view is in place, or currently scrolling, and I have two issues/questions regarding this:

One - I couldn't find an already implemented way of knowing when a scroll view is no longer moving/being collided with by a touch. is there an easy way to check this that is already accessible?

Two - The 'offset' of the scrollView is how I dictate other functions to run. However, I have noticed that offset becomes inaccurate if you scroll off the Device/Editor screen and then let it spring back. Doing this usually makes the offset a few decimals off, but I need it to be exact all the time. is there a reset function I can call to fix this when it happens?

Thank you for all the help,

cruncher3019


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Scrollview Offset Inaccurate
« Reply #1 on: December 23, 2014, 12:01:02 PM »
1. UIScrollView.onDragFinished / UIScrollView.onStoppedMoving

2. Not sure what you mean by offset of the scroll view.

cruncher3019

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: Scrollview Offset Inaccurate
« Reply #2 on: December 23, 2014, 01:48:07 PM »
1. UIScrollView.onDragFinished / UIScrollView.onStoppedMoving

2. Not sure what you mean by offset of the scroll view.

1. Thank you.

2. Sorry, the offset I'm referring to is the "clipping offset". I get the x value of that offset and divide it by the cellWidth to get -1, 0, or 1.

The issue is that the offset is incorrect after it springs back, but only if you drag off of the game screen first and then let go of the object you're scrolling.

Instead of being 0, for example, it could become 7, even though the position of the scrollview is the same.


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Scrollview Offset Inaccurate
« Reply #3 on: December 24, 2014, 07:05:19 AM »
Clipping offset is used by the scroll view to move the contents while scrolling. I don't understand why you need to adjust it yourself? When the clipping offset gets adjusted by some value, the transform position gets adjusted by the inverse of that value.

cruncher3019

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 2
    • View Profile
Re: Scrollview Offset Inaccurate
« Reply #4 on: December 31, 2014, 11:06:20 AM »
I don't need to adjust the offset position. I use the offset position for my own calculations. The issue is that the offset is inaccurate.

If I drag and then let it spring back: When it stops, the offset would not be accurate. It'd be off by 3 - 7 pixels.
« Last Edit: December 31, 2014, 11:21:11 AM by cruncher3019 »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Scrollview Offset Inaccurate
« Reply #5 on: December 31, 2014, 04:03:41 PM »
The offset it springs to is determined by the content of your scroll view and the scroll view panel's bounds + clipping border. There is no guarantee that 0 means "origin".