Skip to content
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

Changing height of SortableItem after drag start breaks size calculations #83

Closed
nervetattoo opened this issue Nov 10, 2016 · 3 comments

Comments

@nervetattoo
Copy link
Contributor

We wanted to shrink the dragged element onSortStart, but at that time the height of the element is already read and subsequently used for move coordinate calculations. Is there any thing we can hook into in order to set height before it is read, or do we need to start working on an enhancement to react-sortable-hoc?
If element 1 is 500px high and we set it to 50px on sort start, it will displace the following elements 450px too far towards the top of the container.

@clauderic
Copy link
Owner

Hmmm. I haven't given much thought to this scenario, but it is something I'd be willing to support. Not sure what the best approach would be though, because detecting element resize can be tricky.

One way I can think of to solve this in a flexible manner would be by passing in a getHelperHeight({index, collection, node}) function that returns the height of the element. Thoughts?

If you don't mind getting your hands dirty, I'd be happy to look at any PR that would attempt to solve this :)

@nervetattoo
Copy link
Contributor Author

It is tricky, because we probably want to animate the shrink-effect, so it wouldn't help to detect size after the outer onDragStart. In our specific case we are going from dynamic heights to a fixed height, so it could even be a number prop as configuration. But a configuration function would be great as well. I'm happy to come up with a PR, just thought I would ask you first in case you had already though of it, or had ideas :)

@furiousOyster
Copy link

@clauderic do you suppose that instead of copying the raw dom node to the base of the body tag, could it make a new react component, using the SortableItem, and just passing in different props to indicate that it is in drag mode ?
That way, it might be possible to allow people to change whatever they like in the dragable component, even whilst it is in flight, and then measurements could be taken of this on the fly element ?

DimitarNestorov pushed a commit to codemotionapps/react-sortable-hoc that referenced this issue Feb 4, 2019
…-height

Add a getHelperDimensions fn to control SortableItem size. Fixes clauderic#83
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants