Author Topic: scrollview does not snap to top  (Read 10858 times)

Ugur

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 60
    • View Profile
scrollview does not snap to top
« on: November 02, 2014, 11:03:11 AM »
So when using a UIScrollView and having toggled on "Cancel Drag if it fits" for it or if the content inside the scrollview is as tall or taller than the scrollview area (so it would perfectly fit without need for scrollbar or have to scroll anyway) and one drags the scrollview's content up or down, it tweens nicely to snap back to the top of the scrollview area when one releases it.

But when one has "Cancel Drag if it fits" disabled for the scrollview and the content in the scrollview is not as tall as the scrollview's area and then one drags the content and releases it, then snap easing back to the top does not work well for the content.
It works when dragging the content up and releases it, but when dragging it downwards and then releasing it, it only eases to scrollview top position+(difference between scroll view area height and  scrollview content height).
So the scroll content is then floating lower down instead of being moved back up fully to the y offset position of the scrollview.

Is this a known issue? Any thoughts on addressing this/working around it?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: scrollview does not snap to top
« Reply #1 on: November 03, 2014, 06:35:13 AM »
It's not a bug. Cancel drag if fits simply lets you or not lets you drag the content depending on whether if fits or not. It won't snap the content to the top for you. You can change that by setting UIScrollView.SetDragAmount(0, 0, true).

Ugur

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 60
    • View Profile
Re: scrollview does not snap to top
« Reply #2 on: November 03, 2014, 08:59:53 AM »
It's not a bug. Cancel drag if fits simply lets you or not lets you drag the content depending on whether if fits or not. It won't snap the content to the top for you. You can change that by setting UIScrollView.SetDragAmount(0, 0, true).

Hello Aren, thanks for the reply but i think we're not talking about the same thing because what i'm asking for is very standard behaviour for every scrollpane/view out there. When one drags the content down, on release, it should ease back up to the top, just like on iOS scrollviews or any other where one can drag the content with the finger like that.
No matter if one has "cancel drag if it fits" toggled off or on,  i'd assume having "restrict within panel" toggled on  should make it do exactly that (not just restrict it within the panel as in scrolled out at the bottom but also restrict it within the panel as in scrolled further down than content top)
Just triggering UIScrollView.SetDragAmount(0, 0, true) is no good since it makes it just jump to the top, not animate there nicely (as it does when one drags the content downwards outside the scrollview where on release it eases it back using springpanel, so basically it should do the same when dragging it downwards below the top of the content and releasing it).
I'm sending you a pm with a link to a video showing the issue to go sure we're talking about the same thing =)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: scrollview does not snap to top
« Reply #3 on: November 04, 2014, 09:23:36 AM »
Right, that's just how NGUI's scroll views work. Restricting within panel does exactly what it says. There is no "spring to top" option. If you really want it to spring to the top rather than to the point where its content is all visible, you'll need to write a script to do that or modify the code to suit your needs.

Ugur

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 60
    • View Profile
Re: scrollview does not snap to top
« Reply #4 on: November 04, 2014, 10:08:02 PM »
Right, that's just how NGUI's scroll views work. Restricting within panel does exactly what it says. There is no "spring to top" option. If you really want it to spring to the top rather than to the point where its content is all visible, you'll need to write a script to do that or modify the code to suit your needs.

Hm, ok, will do that, but yeah, i think that is a feature one would totally expect the scrollview to have and do automatically =)