Author Topic: How would you add draggable items to example 7 scrollview  (Read 16692 times)

arkon3

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 71
    • View Profile
How would you add draggable items to example 7 scrollview
« on: November 26, 2013, 02:46:11 AM »
Hi,

I need something like the example 7, scroll view (panel) but with being able to drag the contents out of the main scrollview and into another panel, what is the correct method of doing this? Each item in the scrollview already has a draggable component but it seems to use this to scroll the items.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How would you add draggable items to example 7 scrollview
« Reply #1 on: November 26, 2013, 03:25:13 AM »
It might be easier for you to start with the drag & drop example for something like this. In that example the items are located inside a scroll view, but there is no script to do the actual scrolling as doing so would involve adding logic as to determining whether the user is dragging an object or the scroll view.

P.S. I'm likely going to add this as an example when I re-do the examples and tutorials in the coming future.

arkon3

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 71
    • View Profile
Re: How would you add draggable items to example 7 scrollview
« Reply #2 on: November 26, 2013, 04:40:26 AM »
Unfortunately I can't wait for an updated example, and the Scroll view example seems to do more of what I need than the  drag and drop example. I'm going to have to add the logic myself but can you give me a clue as to how I can know the difference between the user dragging the scrollview and dragging an item in it? I can't see how you can tell the difference.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How would you add draggable items to example 7 scrollview
« Reply #3 on: November 26, 2013, 06:15:12 AM »
You basically need to write your own drag starting logic. Have a look inside UIDragScrollView script. It's actually really short, and is what facilitates dragging of a scroll view. In your case you will want to delay the OnPress / OnDrag notifications and instead record the position of the start, then check it in update -- is the movement delta far enough? Then do something. I'd do it so that if you drag it far enough to the left, you start a scroll operation, and if you move it far enough up, you start the drag operation.