Author Topic: iOS Scrolling Emulation  (Read 4093 times)

mixd

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 22
    • View Profile
iOS Scrolling Emulation
« on: November 18, 2012, 07:02:31 PM »
I would ask for this as a feature request, but I'll leave that up to Aren. Here is some code that anyone can drop in their project to make your scrolling windows feel more like native iOS scrolling. The change is subtle yet makes a huge improvement!

[in]
UIDraggablePanel.cs

[change]
  1. // Move the panel
  2. MoveAbsolute(offset);

[to]
  1. // Move the panel
  2. Vector3 constraint = mPanel.CalculateConstrainOffset(bounds.min, bounds.max);
  3. if (constraint.magnitude > 0.001f)
  4. {
  5.         MoveAbsolute(offset / 2f);
  6.         mMomentum /= 2f;
  7. }
  8. else
  9. {
  10.         MoveAbsolute(offset);
  11. }
« Last Edit: November 18, 2012, 07:19:00 PM by mixd »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: iOS Scrolling Emulation
« Reply #1 on: November 18, 2012, 08:00:19 PM »
Try your code with the framerate limit disabled (vsync off).

mixd

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 22
    • View Profile
Re: iOS Scrolling Emulation
« Reply #2 on: November 19, 2012, 03:07:58 PM »
Is this something you would consider adding and/or suggest the proper way to make this work? (Tried w/o vsync and it seemed ok but I was not sure what I was looking for)


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: iOS Scrolling Emulation
« Reply #3 on: November 19, 2012, 04:12:46 PM »
Ok I looked deeper into your changes. I misunderstood what happens originally. Looks fine to me, I'll integrate them into the main repo, thanks.

nah0y

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 430
  • \o/
    • View Profile
Re: iOS Scrolling Emulation
« Reply #4 on: November 20, 2012, 10:04:13 AM »
Hum, I've tried your code and it doesn't seem to do anything different with or without :s

Is it something really visible ??

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: iOS Scrolling Emulation
« Reply #5 on: November 20, 2012, 03:41:51 PM »
Took me a while to see the effect as well, nah0y. Try dragging the contents past the bounds. It halves the drag amount, making it seem like there is some resistance being applied.

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: iOS Scrolling Emulation
« Reply #6 on: November 20, 2012, 05:14:50 PM »
This is excellent for iOS apps as we can match the native behavior better. Good job, mixd!

nah0y

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 430
  • \o/
    • View Profile
Re: iOS Scrolling Emulation
« Reply #7 on: November 21, 2012, 12:14:52 PM »
Nice !

Yup, closer but still not the same fluid feeling we have on an iOS list. And I don't think we will get near that using Unity (am I right ?).

PS : You're going to include this for the next release right ? :)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: iOS Scrolling Emulation
« Reply #8 on: November 21, 2012, 05:32:23 PM »
Yeah, Pro users already have it in the repo.

nah0y

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 430
  • \o/
    • View Profile
Re: iOS Scrolling Emulation
« Reply #9 on: November 21, 2012, 06:41:20 PM »
I should consider getting the pro version :)