gridstack.js icon indicating copy to clipboard operation
gridstack.js copied to clipboard

Cannot move widget horizontally (Allow horizontal swapping without creating new rows)

Open amrbahaa opened this issue 11 years ago • 50 comments

for example : i have a grid with fixed 4 columns and four rows When i was trying to move the widget Horizontally and no place for the other widgets to slide up or down , the end result is you will not be able to move that widget unless there is enough space for other widgets to slide up/down.

is there any way to make the other widgets to slide left/right? so i can move any widget when i have a fixed width and height grid with full capacity widgets.

amrbahaa avatar May 24 '15 13:05 amrbahaa

I guess this is still in the works? Setting height: 1 does not allow me to swap or move items.

steezeburger avatar Feb 22 '16 18:02 steezeburger

That's correct. I believe it will be readied for v1.0.0. It may be in 0.3.0, but is very unlikely to make it into the current dev build. As you can see, the issue remains open and will stay open until it's been resolved.

radiolips avatar Feb 22 '16 18:02 radiolips

Awesome, I'll play around with the patch above as it fits my use case and then wait for an official fix later on. Thanks for the quick reply.

steezeburger avatar Feb 22 '16 19:02 steezeburger

May i know when v1.0 will be release for this enhancement feature?

tchyong avatar Mar 18 '16 03:03 tchyong

@h-nazzal with what version does your code work ? I know it doesn't work with the latest one but I tried with v0.23 which was released last year and even with that it's not working. I am trying with equal size widgets. Any help would be appreciated.

mandys avatar Apr 01 '16 11:04 mandys

@h-nazzal May i know when will be release for horizontal swapping?

nikunjit101 avatar Apr 29 '16 11:04 nikunjit101

sorry guys ... but that wont be happening. i have hit a huge wall trying to make the plugin make the desired effect.

h-nazzal avatar May 01 '16 00:05 h-nazzal

If you want to use the snippet above watch out for the function naming. I got it working in v0.2.6 after replacing the above snippet with the code in gridstack and adjusting the function name from GridStackEngine.prototype._fix_collisions to GridStackEngine.prototype._fixCollisions (like the default function is called in gridstack).

puresick avatar Dec 08 '16 15:12 puresick

Widget swapping – A much-requested feature, we’re working on a way to make widgets swap places so that widgets may still be moveable even in a full grid.

will this devloped in next version?

eagoo avatar Sep 19 '17 09:09 eagoo

@eagoo @h-nazzal @radiolips Just a small remainder... When this feature is available?

Shiva4393 avatar Jan 16 '18 05:01 Shiva4393

I am having the same issue. Can anyone let me know whether this is resolved. if yes, please let me know the version to take.

sailajachellu avatar Jan 24 '18 06:01 sailajachellu

@Shiva4393 @sailajachellu im not working on this anymore. as i have said before i moved to my own custom solution.

h-nazzal avatar Jan 31 '18 04:01 h-nazzal

Keen to see this feature too if someone else can develop a solution.

jamdav16 avatar Jan 31 '18 10:01 jamdav16

@h-nazzal Can you please share your custom solution with an example which fixes this issue?

Shiva4393 avatar Apr 18 '18 09:04 Shiva4393

+1 Do you have any news for this issue ?

Altraya avatar Jul 15 '19 14:07 Altraya

@h-nazzal

i know that exact code that is responsible for the behavior and it's just a simple fix. .... the code below is proven to be non-working....I'm going to go for a full rewrite of the collision detection mechanism as working with it is seriously hard.

aaah... aaah :) guessing we never had a working (non trivial same size) working version ? I might take a look at the current heuristic as it doesn't appear to move objects when past half point (like #1094), and could check for swap if size happen to be the same. No promise

adumesny avatar Dec 22 '19 02:12 adumesny

Hi guys, is it still work in progress? Would be nice to have this maybe as a gridstackoption... Having only 3 items in a 1 row and 3 column width, all items same width and height, want to have the possibility to move item 1 to position of item 3 and have them just swap positions, possible?

kevinlandsberg avatar Dec 09 '20 12:12 kevinlandsberg

I started looking at it last weekend and may have to re-write entire collision heuristics at some point... $$ donation would certainly help as this is a BIG task.

Update: I should have some time during the holidays to look at this now that 3.x Html5 is out and solid.

adumesny avatar Dec 09 '20 18:12 adumesny

Update: I spent the weekend on this and have swapping on same sized items working in a private branch, which is now the default for top gravity float: false rather than push down (feels more natural IMO), and also used on floating grids if the grid is full and cannot create new rows (maxRow set). Also fixes going down and not swapping right away until you are past the same sized object, and bunch of other oddities and Inefficiencies...

Still need to prevent larger items from swapping unless they are 50% covered, doing collide on the most covered item (not first one) and lot more testing... Hopefully this 5y old most wanted feature will make it now...

Horizontal swapping of different sized objects will need to wait for gravity: left feature (#754) which is a totally different ball game.

adumesny avatar Dec 14 '20 16:12 adumesny

Behaviour like this is expected:

http://sortablejs.github.io/Sortable/#grid

kevinlandsberg avatar Jan 29 '21 09:01 kevinlandsberg