Author Topic: UIScrollView.onDragFinished is not called when centerOnChild exists  (Read 201 times)

Andrey Postelzhuk

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
'onDragFinished' callback is never called when UIScrollView has centerOnChild object.
  1. else if (centerOnChild)
  2. {
  3.         centerOnChild.Recenter();
  4. }
  5. else
  6. {
  7.         if (mDragStarted && restrictWithinPanel && mPanel.clipping != UIDrawCall.Clipping.None)
  8.                 RestrictWithinBounds(dragEffect == DragEffect.None, canMoveHorizontally, canMoveVertically);
  9.  
  10.         if (mDragStarted && onDragFinished != null) onDragFinished();
  11.         if (!mShouldMove && onStoppedMoving != null)
  12.                 onStoppedMoving();
  13. }
  14.  

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 278
  • -Receive: 1133
  • Posts: 21,902
  • Toronto, Canada
    • View Profile
Re: UIScrollView.onDragFinished is not called when centerOnChild exists
« Reply #1 on: April 22, 2017, 11:21:38 AM »
Recenter() continues the move operation to smoothly animate the scroll view to the target position, so calling "finished moving" when in fact it's still moving might be odd. Still, you can just add it and see if it causes any issues:
  1.                         else if (centerOnChild)
  2.                         {
  3.                                 if (mDragStarted && onDragFinished != null) onDragFinished();
  4.                                 centerOnChild.Recenter();
  5.                         }