Hello,
I need to be able to move an Intractable.View to a snapPoint by providing the index. I've tried with setVelocity, but the problem is that the view is moved relatively to it's current position. I have a lot of items on my screen that need to be swapped when you drag one on another.
How can I achieve that ?
I'm not really sure I understand the use-case, can you explain it with more detail please?
Very simple example of my use case :
I have 3 Intractable.View and each of them have 3 snapPoints corresponding to the other views placement.
Something like that :
snapPoints={[
{x: 0},
{x: 100},
{x: 200}
]}snapPoints={[
{x: -100},
{x: 0},
{x: 100}
]}snapPoints={[
{x: -200},
{x: -100},
{x: 0}
]}I also have an array telling me which view is at which index : [1, 2, 3]
Now I want to drag my first view on to for example the third snapPoint (x: 200) and my third view should automatically snap to it's first snapPoint (x: -200) because the sender had index 1 in my array.
Now my array looks like that : [3, 2, 1].
I could achieve that with setVelocity but I would have to do a lot of if statements based on the sender id and it's current index. But I want to know if there's an easier way for example telling to a view : "Now snap yourself to the snapPoint at index 1"
I added to master an imperative command called snapTo which does what you want. iOS only for now. @ButtersHub can you add Android support?
sure, ill do it.
@talkol Thank you very much ! Saves me a lot of time ! Very great work here :)
Android implemented as well.
I love the short response time here guys! Keep up the good work <3
Please reopen if anything still needs to be improved
guys! a silly question, sorry how can we do a snapTo with animation?
@leshaivanovsky I think that it's animated by default...
Most helpful comment
Android implemented as well.