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

Is it possible to have different layout only during dragging? #509

Open
jiniC opened this issue Jan 3, 2022 · 1 comment
Open

Is it possible to have different layout only during dragging? #509

jiniC opened this issue Jan 3, 2022 · 1 comment
Labels

Comments

@jiniC
Copy link

jiniC commented Jan 3, 2022

Hello, I posted another question right below. murri seems like a very nice library, so I'm constantly testing the various specs.
Then again, there is a blockage, so I inquire.

When I drag an item, I want to expose it by narrowing the height of all the items, and then return it to its original state when the dragging is finished. (like google cloud platform dashboard : https://console.cloud.google.com/home/dashboard)
As in the example of Google Cloud Platform, I am also trying to place items with different height values.
I'm testing using the supported events, But it wasn't easy...

In particular, I'm having a hard time finding an easy way to do the following.

  • How to find out which item is located at the top of a column : I added col value as an attribute by calculating based on the layout drawn when the layoutEnd event is called.
  • How to operate with the layout rule set during dragInit during dragging : I have no ideas. 😥

So I leave a question. Any good ideas for implementing this using murri ?

I also attach an example gif file of the function I want to implement using murri 🥺
drag

@jiniC jiniC changed the title Is it possible to have different layout layouts only during dragging? Is it possible to have different layout only during dragging? Jan 3, 2022
@niklasramo
Copy link
Collaborator

@jiniC This is an interesting question! And a good use case, which should definitely be supported by Muuri, so let's dig in and see if it's possible :)

My first question is that are the columns separate Muuri containers (3 Muuri instances) or is there just one big grid (1 Muuri instance)? If this is a kanban-like setup you should be able to build the GCP Dashboard example with Muuri pretty easily. However, if it's just one big grid then things get more messy (but should still be doable in theory, there are just some big UI issues not related to Muuri specifically).

To make the kanban-like version work you really don't need to do anything special other than setting the muuri item height to match the height of the item header for all items you want to minimize during drag. Then just call grid.refreshItems().layout() for all the respective grids. You'd want to do this on dragInit event. And then on dragReleaseEnd you'd want to unset the forced height of the items and again call grid.refreshItems().layout(). The only real problem is making the item minimize animation behave nicely and in sync with Muuri, but there are plenty of ways to do that. Here's quick example on an example implementation: https://codepen.io/niklasramo/pen/JjOjxay

I hope this helps :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants