Author Topic: UIScrollview scroll offset  (Read 6000 times)

e-tip

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 10
    • View Profile
UIScrollview scroll offset
« on: May 06, 2015, 10:53:33 AM »
Hi everyone.
I've got a UIScrollview and in that scrollview i want to implement a pull to refresh function.
i've added the onDragStart and onDragFinish Event to my script but i can't find a way to calculate/obtain the offset when the user ends to drag. Does anyone have any suggestions ?
my goal is to introduce a threshold so reload function is called only when the offset is bigger than threshold
thanks in advance

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIScrollview scroll offset
« Reply #1 on: May 07, 2015, 06:49:56 PM »
Have a look at UIPanel.CalculateConstrainOffset function. It does exactly what you're looking for.

e-tip

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 10
    • View Profile
Re: UIScrollview scroll offset
« Reply #2 on: May 13, 2015, 05:50:40 AM »
Wow... Thanks

Aastha

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 18
    • View Profile
Re: UIScrollview scroll offset
« Reply #3 on: May 19, 2015, 11:58:32 PM »
Hi,
Can you explain this further how this function can be used to implement pull to refresh.
Thanks in Advance.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UIScrollview scroll offset
« Reply #4 on: May 22, 2015, 03:50:10 PM »
That function will give you (0, 0) if you are observing your panel normally, and something other than 0 if you have scrolled outside the bounds. Just try using it.