vue-grid-layout icon indicating copy to clipboard operation
vue-grid-layout copied to clipboard

max-rows overflows on reorder

Open aarcane opened this issue 7 years ago • 22 comments

When max-rows is set, columns can have more than max-rows rows when items are dragged into said row.

For a specific example: I have an 8x4 layout with 4 rows and 8 columns. When I fill the first column with 4 rows, then I drag an item into the column in the middle ([0,2]), then the last item gets pushed down. When I finish the drag event, the first column now has 5 rows, which is more than max rows.

Proposed fixes:

  1. prevent dragging into a full row.
  2. When dragging into a full row, overflow the item out of the row. Place it in the first unused row in the first non-full column.

aarcane avatar Feb 28 '18 23:02 aarcane

+1 very problematic

pat123456 avatar Apr 27 '18 20:04 pat123456

+1

gracefullight avatar Oct 22 '18 14:10 gracefullight

Any headway on this? It's a problem for me also

SethMcFarland avatar Nov 06 '18 23:11 SethMcFarland

+1

hz47 avatar Dec 04 '18 19:12 hz47

why not work max-rows?

SavaJankovic avatar Dec 21 '18 19:12 SavaJankovic

+1

wmq2015 avatar Mar 30 '19 08:03 wmq2015

+1

boriskogan81 avatar May 08 '19 11:05 boriskogan81

+1

igormatkovic avatar May 21 '19 22:05 igormatkovic

+1

anniestudent avatar Jul 16 '19 08:07 anniestudent

anyone have any idea?

vohzd avatar Dec 05 '19 21:12 vohzd

+1

zggcl avatar Apr 21 '20 03:04 zggcl

+1

cosfun avatar Jun 02 '20 05:06 cosfun

+1

Aljodomo avatar Sep 07 '20 12:09 Aljodomo

+1 for the unexpected behavior.

However, there are ways you can circumvent this. Personally, I fill my grid upfront so every spot is taken. The next thing you can do is listen to the moveEvent and swap the currentItem with the swappedItem (own names, don't shoot me) if the x value of the currentItem is not the same as the newX.

Example Code:

  • We want a grid of 5x5

1. Fill Grid beforeMount () { for (let i = 0; i < 25; i++) { this.layout.push({ i: i, x: (i % 5), y: Math.floor(i / 5), w: 1, h: 1, static: false }) } },

2. React to moveEvent methods: { moveEvent: function (i, newX, newY) { const currentItem = this.layout.filter((item, index) => { return i === index })[0] if (currentItem.x !== newX) { const swappedItem = this.layout.filter((item, index) => { return item.x === newX && item.y === newY })[0] swappedItem.x = currentItem.x swappedItem.y = currentItem.y } } },

Example Video:

  • https://user-images.githubusercontent.com/3932284/104223815-6a212b00-5444-11eb-9173-654789b709ed.mov

dhondtlaurens avatar Jan 11 '21 18:01 dhondtlaurens

+1

I am having the same issues however I have tried implimenting the solution above and this works great for items in the grid that are only 1x1 it starts to struggle when you have a mixture of sizes for the items.

It would be great if we could have functionality or a property that stops the items from overflowing out of the grid and out of the parent container.

The prevent collision property seems to be as close as I can get at the moment but this then doesn't allow items to be "swapped" only placed in free space.

Any idea on when this issue would be solved as it seems like a lot of people are having the same problem hence the duplicates of this issues.

samwilcock avatar Feb 05 '21 15:02 samwilcock

How this max-rows property actually works?

casyalex avatar Mar 25 '21 06:03 casyalex

Is there any hope that this will be fixed in the near future?

ByleX1337 avatar Oct 26 '21 09:10 ByleX1337

@ByleX1337 can you submit a PR to fix it?

gmsa avatar Oct 26 '21 10:10 gmsa

+1, that's still an issue

koljada avatar Dec 09 '21 09:12 koljada

@jbaysolutions you died?

mes01 avatar Aug 30 '22 15:08 mes01

@jbaysolutions you died?

Want to contribute with a fix yourself?

gmsa avatar Aug 30 '22 16:08 gmsa