Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drag and drop #54

Closed
wants to merge 3 commits into from
Closed

Drag and drop #54

wants to merge 3 commits into from

Conversation

jwilling
Copy link
Owner

@jwilling jwilling commented Oct 8, 2013

_Work in progress. Do not merge._

This is a difficult problem to generalize for all layouts. I was discussing this with Marc Haisenko, and it clarified a couple things for me.

There should probably be two types of reordering. I'll paste what Marc aptly wrote:

  • Displacing: a placeholder (or empty view) is drawn where the drop will occur, the other views are pushed away.
  • Marking: a marker is drawn in such a way that no existing items need to move. For example, try to move an item in Xcode's file tree: a blue marker is drawn where you'd like to drop. This also detects into account on which level you want to drop.

To me, it seems like the default type here should be displacement. The reasoning for that is that drawing a marker can really only be generalized to linear layouts. Displacement should theoretically work for all types of layouts.

There are many components that need to go into this. My proposal is this.

JNWCollectionViewReorderableLayout
This will be a subclass of the regular layout. This would encapsulate many of the patterns that are in common with all types of drag and drop operations. Any layouts that want to opt-in to reordering can then subclass this class instead of JNWCollectionViewLayout. This class will be responsible for handling all aspects of both marker and displacement-based layouts. That means that in the case of displacement-based layouts it will take any layout attributes it receives from any subclasses and will modify those as necessary to displace elements.

Now here come the more interesting questions that I haven't figured out yet.

  1. What should be responsible for auto-scrolling the collection view? The layout? Should it be forwarded to the collection view, which it can then handle itself?
  2. We need to add onto the existing delegate methods to ask the delegate whether it wants to allow the proposed drop, and also to inform it that a drag and drop happened.
  3. How will this be synced with the data source? Ideally this should co-exist with APIs for inserting / deleting / moving items.
  4. How can we allow customizability of the displacement animations? Should this be part of my grand plan for allowing custom animations for specific events in the layout (e.g. insertion, deletion, moving)?

(Fixes #11)

@jcampbell05
Copy link

Any progress on this ?

@jwilling
Copy link
Owner Author

Sadly not. It's likely this won't ever get completed. It might be worth checking out this pull request if you're looking for an implementation of this. There were reasons I had for not wanting to merge it, but it does work. It's out of sync with the current state of master, for what it's worth.

@markmark1
Copy link

This will be a great addition to an already awesome jnw

On Thu, Jun 11, 2015 at 2:13 AM, Jonathan Willing
notifications@github.com wrote:

Sadly not. It's likely this won't ever get completed. It might be worth checking out this pull request if you're looking for an implementation of this. There were reasons I had for not wanting to merge it, but it does work. It's out of sync with the current state of master, for what it's worth.

Reply to this email directly or view it on GitHub:
#54 (comment)

@jcampbell05
Copy link

Yeah looks like the new NSCollectionview has custom layout, so will be good stop gap until then.

@jwilling
Copy link
Owner Author

I'm not sure if I'm misunderstanding y'all, but what you see in this branch is probably not going to ever be completed. If you're referring to the pull request I mentioned, then yes, hopefully that can suit your needs.

@jwilling
Copy link
Owner Author

See #156 for a possible implementation.

@jwilling jwilling closed this Dec 30, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add the ability to drag & drop to rearrange items in the collection view
3 participants