Replies: 1 comment 1 reply
-
Interesting demo! I'll be sure to test this out on the next RC before it's released to see if it surfaces any bugs. 👍 |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello react-spring community! Let me start by thanking the maintainers for their hard work on this magic library!
I've been working on and expanding the draggable list demo with a few features. Some I've been (to some extent) successful at, others... eh, not really. I'll use this post as a way to share examples for anyone who might find them useful, and, at the same time, to ask for some help in solving some issues.
Features added on top of the
useSprings
demo:true
, shrinks the list from the contentauto
height to a fixed one (almost done)onSortComplete(newOrder: number[])
callback with the new order that can be used to re-render the list with the new order (almost done)CodeSandbox Link
Toggle sort mode
Say you want to sort long paragraphs of selectable text, or anything that has
auto
height or a very long height, then I think it's useful to be able to toggle a 'sort mode' in which the list items change props and have a fixed height.For example, on LinkedIn, if you have an education entry with a very long description and your browser window is smaller than its height, you won't be able to sort it at all. This is also where the relatively positioned elements and the automatic edge scrolling features come into play.
Issues to solve:
onSortComplete(newOrder)
callback is provided, the list elements change into the new order either animating (ignoring theimmediate
attribute) or in a weird two-frame animation, which you can see below. Here, there definitely is some gotcha I don't understand about react's lifecycles, and would appreciate any tip. I've read the complete guide touseEffect()
but I can't wrap my head around it completely apparently.Thank you in advance for your help! ✌️
Beta Was this translation helpful? Give feedback.
All reactions