-
Notifications
You must be signed in to change notification settings - Fork 85
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 (With Latest JNWCollectionView Code) #156
Conversation
Closing other pull requests in favor of this one. I don't want to merge this in its current state, but I'll leave it open for anyone interested in implementing this functionality. For further references on other implementations and designs, see the following pull requests: |
Just a side note. Regarding the blank spot code, there is a library (I'll find it later and edit this comment) that implements drag and drop for iOS table view. It would be a great one to be inspired by for this functionality. |
@jcampbell05 Like this one? https://github.com/lukescott/DraggableCollectionView I've used this for a project before and it has the sort of functionality for "blank spots" that I'd be looking for. I'm not sure how well the code would translate to JNWCollectionView, but really, I might be overthinking how complicated it should be. The pertinent code would probably be put inside the prepareLayout function, so it'd just take some logic rearranging to insert a "blank" item. I think another delegate method to grab the "empty" cell for the drag/drop view would be appropriate. It would function exactly like |
@Deadpikle Yeah, also I think now 10.11 now finally has a collection view class like iOS with drag and drop support it is better to use that. |
Yes, I should really update the readme, as this is now soft-deprecated. I recommend using |
The new NSCollectionView looks promising until you notice that just scrolling up and down will leak memory like crazy. Nice try Apple... But an epic fail memory wise :-( |
@objectivesheep I actually haven't noticed that behavior during my experiences with |
Actually any tutorial project I downloaded can show this... Even Apple's Having said that if you find that I'm wrong and that there's a way to use That would be heaven for me :-)Fabio Russo |
Just one more example. I downloaded this simple project (https://github.com/klaas/CollectionViewElCapitan) and it works great. When I fire it up with some added strings in the initial array it starts with 18MB of memory usage in Activity Monitor. I played around with just scrolling the list and resizing the window for about 5 minutes. Memory is now 74MB! |
Ok I have to take that back. Tried it some more and in more depth. The memory footprint can get a little large now and then but after a while it always goes down. I've especially noticed a big difference when using binding or not (no binding is usually empirically a smaller footprint). So ok for the new NSCollectionView. It works for me. |
Cool. That memory usage doesn't sound too high considering the number of views / layers visible at any given time. Making the window smaller generally puts more items into the cell reuse queue, which isn't always cleaned up. That means that even if you make your window small again the pool remains the same size, leading to no drop in memory usage. |
Closed in order to clean up my fork's repo, which was starting to become a mess because I did drag+drop things on 'master' instead of on a branch. I deserve a slap on the wrist for that. :) |
Here's an implementation of Drag and Drop that runs off of the latest version of the JNWCollectionView code. It was based off of the work done by DarkDust at https://github.com/DarkDust/JNWCollectionView. The implementation is not the most beautiful thing in the world, and there could easily be some more work done on it, and I'll be the first one to claim that. I don't really have time to work on this at the moment. Of course, others can always pitch in and clean up!
Notable things that could be cleaned up:
For those of you wondering why I'm adding a 3rd pull request for drag and drop, I asked for permission first. Thanks, Jonathan!