Hello Guest

Author Topic: tk2dUIScrollableArea sometimes "sticks" on devices (iOS/Android) when swiping  (Read 7419 times)

zblack

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 22
    • View Profile
Heading says it all: When trying to swipe/flick to scroll, the content will just dead-stop the instant you release your finger. Happens anywhere between 10-20% of the time depending on the device. Has anyone else encountered this and found a fix?

(Previously, when I coded my own scrolling area for iOS in Xcode using C++, I ran into this problem as right away, and had to do some trickery to prevent it from happening. I was surprised to see that it had not been addressed in tk2d.)

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
I've not seen that happen on iOS at all - we test on iOS a lot more than Android. Its impossible to guess what the cause is without seeing and debugging it. If you do find a reliable way to reproduce this post the device & instructions and I'll investigate if I can get my hands on the same device.

Edit - only thing I can think of is that its registering another touch down & up immediately after letting the first one go, like a bounce.

zblack

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 22
    • View Profile
The problem is the line "swipeCurrVelocity = ... " in UpdateSwipeScrollDestintationPosition() of tk2dUIScrollableArea.cs. What happens is that the value can be set to 0 if the user happens to release their finger on the frame that a swipe delta had just begun to calculate (i.e., the start point and end point are equal). The "quick fix" is to merely check if the two value are equal, and if so, don't re-calculate swipeCurrVelocity. It will be left with it's previous delta value and you'll get good velocity on all releases. I tried a couple of other techniques, including weighting and averaging the two values together, but inevitably you get "sticky" swipes at 1/2 speeds and such. Ideally, the algorithm should be keeping a running weighted average of the last several swipe deltas over time, and use that averaged value to set swipeCurrVelocity on release.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Cheers for that. This is all very familiar, I can't quite place it, almost like some kind of I've fixed this before deja-vu. I'll have a poke around the old source repos in case it was something that was never checked in...

zblack

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 22
    • View Profile
So I realized a problem with my "fix": If you *intend* to release the scroll area without moving it (points are equal), it still moves! Yergh. So really the only way to properly fix this is an average of the last several deltas, so if you hold in place for a second and then release they will all be zero.