Skip to content

A demo for horizontal swapping #604

@Jacks349

Description

@Jacks349

I went through the issues and found that some people wanted to have some sort of system to allow horizontal swapping between items, where two items on the same row can be swapped without touching the rest of the grid. I needed this too but it looks like vue-grid-layout doesn't support it for now, and since i really like this library and i need it, i decided to give it a try and implement it myself.

The solution i came up with is very basic: it uses the moveEvent() and preventCollision set to true to detect when an item is being dragged over another item, and when it does it will swap the position of the two items in the grid. It seems to work, but since my code is not so good and it's very basic (it needs to be tested and adapted to work in all the cases) i decided not to create a PR but instead i created this issue, so that it can be a starting point for anyone else who needed this or wanted to improve this solution.

Here is a simple codesandbox: https://codesandbox.io/s/dazzling-burnell-rmwbk?file=/src/App.vue

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions