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

Collapse draggable item #54

Open
raunofreiberg opened this issue Oct 7, 2020 · 5 comments
Open

Collapse draggable item #54

raunofreiberg opened this issue Oct 7, 2020 · 5 comments
Labels
question Further information is requested

Comments

@raunofreiberg
Copy link

Hey,

Thanks for the great library! I have a use case that doesn't seem to be possible.

On drag, I would like to collapse the item along with it's hidden clone. This is quite useful for long lists where items can be pretty large in height. Collapsing them helps navigate through this list.

I tried doing something like:

height: isDragged ? "50px" : "100px",

on the component in renderItem but only the ghost item seems to change height, but not the hidden one?

Here's an example: https://codesandbox.io/s/sad-einstein-u7feh?file=/src/App.js:1160-1212

Thanks!

@raunofreiberg
Copy link
Author

I can collapse the draggable item by doing:

height: isDragged || props.style.visibility === 'hidden' ? "50px" : "100px",

But this still requires me to drag over the initial height of it:

Kapture 2020-10-07 at 12 00 14

@raunofreiberg
Copy link
Author

@tajo any ideas here?

@tajo
Copy link
Owner

tajo commented Oct 12, 2020

Utilizing beforeDrag could get you closer: https://codesandbox.io/s/romantic-cookies-7odri?file=/src/App.js

However, onChange is not called when the item position is not changed so the height doesn't reset. Maybe we could add afterDrag or having some better API for this use-case (explicit draggedHeight prop?). Although, it seems too rare of a use-case to just add a new API for this, so maybe more general afterDrag to fix my workaround would be the best.

@tajo tajo added the question Further information is requested label Oct 16, 2020
@raunofreiberg
Copy link
Author

afterDrag would work for me! With some direction, I could open a PR, if you'd like?

@tajo
Copy link
Owner

tajo commented Oct 19, 2020

@raunofreiberg Yea, go for it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants