React-native-swipe-list-view: Deleting over Action slower than onSwipeValueChange

Created on 2 Jun 2020  路  6Comments  路  Source: jemise111/react-native-swipe-list-view

Hello,
first of all thank you for this amazing work!
I麓m using a swipetodelete behaviour in my list and recently switched to deleting with actions, like in the actions example. Before that I used the method shown in the swipe_to_delete example. The delay in time it takes to start the Animation is in the actions example (rightActionState) higher than in the swipe_to_delete example (swipeData). This behaviour can not just be seen in my implementation, but also in the example app. Is there a way to shorten the delay when using actions? Perhaps by constantly checking the swipeAnimatedValue/ _translateX animated value?
Thank You!

All 6 comments

Hey @alexco2, I definitely see what you mean. I think what's going on here is that in the swipe_to_delete example you have direct control over when to trigger the delete animation because you are tracking the swipe value yourself.

In the actions example I believe you wait for one full render cycle before the action is triggered. Which might be the delay you are seeing. Actions already works by tracking the translateX value so I'm not sure if we can make that one faster.

I'll cc @proof666 who wrote the code for Actions who might be able to provide more insight

Thank you @jemise111 for your answer! Before I controlled every posible swipe interaction in a huge onSwipeValueChange function. Now the logic is outsourced into each ListItem component, which is defently easier for the eyes ;) It would be amazing if there would be a way to combine a fast animation response and actions :)

Yeah I think that's sort of the tradeoff between direct tracking of the translate value and more complex code vs letting the library handle the tracking but waiting longer for the trigger. I'll see if there's anything I can do to combine them though..

Do you think a acceptable solution might be tracking both? Conrolling/starting the animation by tracking directly through onswipevaluechange and still handle the rest of the logik (what to do with the data that was swiped) with actions? Or would that be an unnessecary performance loss?

Hm.. TBH I think the best thing you can do is implement whatever you think is best and then do some performance testing and see how it feels. I try to stick to the motto of not implementing performance enhancing solutions until they are necessary

However I will say that actions will add an additional listener to the translate value (https://github.com/jemise111/react-native-swipe-list-view/blob/master/components/SwipeRow.js#L139). I don't think this should affect performance too much but if you want to limit listeners to the smallest number possible you should go with the single direct tracking approach instead of combining the two.

But again, this is just speculation. I'd do whatever is best for you and then investigate perf after the fact

If it's cool with you @alexco2 I'm going to close this one, but if you think more work should be done here feel free to reopen, thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kopax picture kopax  路  4Comments

bohdan145 picture bohdan145  路  6Comments

Elijen picture Elijen  路  5Comments

terencestone picture terencestone  路  5Comments

kyangy picture kyangy  路  3Comments