Author Topic: How to start a Scroll View list at the top?  (Read 1946 times)

Slydog

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 10
    • View Profile
How to start a Scroll View list at the top?
« on: April 26, 2013, 12:39:33 PM »
I'm not sure if it's the default behavior, or something specific to my project, but my first scroll list item (in a UIGrid vertical layout) starts in the center of the panel, not at the top.  As soon as I drag the contents a bit, it snaps/scrolls itself to the top properly.

Is there a method I can call to automate a simulated drag - to force the animated momentum and spring effect? 

I've tried a variety of combinations of the following commands, but none did what I expected:
(Maybe because I wasn't sure what units / scale the calls were expecting.)
  1. uiDragPanel.Drag(new Vector2(10, 10.1f));
  2. uiDragPanel.MoveRelative(new Vector3(0f, 240f, 0f));
  3. uiDragPanel.MoveAbsolute(new Vector3(0f, 0.75f, 0f));
  4. uiDragPanel.restrictWithinPanel = false;
  5. uiDragPanel.restrictWithinPanel = true;
  6. uiDragPanel.ResetPosition();
  7. uiDragPanel.Scroll(-0.01f);

Even cooler would be for the first item to start at the bottom - just out of view, then have the list animate towards the top using the spring animation.

Thanks,

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,151
  • Toronto, Canada
    • View Profile
Re: How to start a Scroll View list at the top?
« Reply #1 on: April 26, 2013, 01:08:52 PM »
Add your item at edit time. Where you see it is going to match what you see when you add it dynamically at run-time. Now reposition the grid so that it's in the position you want it to be. Now delete the item and hit Play.

Slydog

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 10
    • View Profile
Re: How to start a Scroll View list at the top?
« Reply #2 on: April 29, 2013, 03:17:59 PM »
Thanks, it works and looks great!
So simple!