TextureGroup / Texture

Smooth asynchronous user interfaces for iOS apps.
https://texturegroup.org/
Other
8.02k stars 1.29k forks source link

Feature Request: collectionNode(_:targetIndexPathForMoveFromItemAt:toProposedIndexPath:) #1993

Open SleepiestAdam opened 3 years ago

SleepiestAdam commented 3 years ago

I'm attempting to implement interactive moves into my ASCollectionNode...

Unfortunately, my collection node is made up of both re-orderable and non-reorderable elements and cells should only be movable within the movable range e.g:

[Non movable title cell] [Movable Item] [Movable Item] [Movable Item] [Movable Item] [Movable Item] [Non movable item] [Non-movable item] [Non-movable item]

Due to the fact there is no equivalent of collectionView(:targetIndexPathForMoveFromItemAt:toProposedIndexPath:), currently while I can prevent the non-moveable items from being "picked up" for re-ordering (via collectionNode( collectionNode: ASCollectionNode, canMoveItemWith node: ASCellNode)), it still allows users to drag movable objects in and around the non-movable ones.

I'd therefore like to request the addition of an equivalent of collectionNode(_:targetIndexPathForMoveFromItemAt:toProposedIndexPath:)

Many thanks!

agibson73 commented 1 year ago

@SleepiestAdam what was your fix here? I am just encountering something similar? Any updates on this issue?

** Maybe there is a more default solution but I only needed to prevent the very last node from moving so I implemented handleLongGesture and manipulated the position passed

var newLocation = gesture.location(in: gesture.view!) let ip = IndexPath(item: lastIndex, section: 0) if let _ = self.collectionView.nodeForItem(at: ip) as? FSAddNewSceneNode, let rect = collectionView.view.layoutAttributesForItem(at: ip){ newLocation.x = min(rect.frame.origin.x - rect.frame.width/3,newLocation.x) }

//this prevented the last cell from moving collectionView.view.updateInteractiveMovementTargetPosition(newLocation)