An open API service indexing awesome lists of open source software.

https://github.com/radekvym/draggable-grid-js

JavaScript control that allows you to arrange items into a grid and to move between them by dragging.
https://github.com/radekvym/draggable-grid-js

animations component control drag draggable draggable-elements grid-layout javascript javascript-library web

Last synced: 11 months ago
JSON representation

JavaScript control that allows you to arrange items into a grid and to move between them by dragging.

Awesome Lists containing this project

README

          

# Draggable Grid

JavaScript control that allows you to arrange items of an unordered list into a grid and to move between them by dragging.

[![Sample GIF](./images/sample.gif)](https://radekvym.github.io/Draggable-Grid-JS/index.html)

See [live demo](https://radekvym.github.io/Draggable-Grid-JS/index.html).

## Usage

Import styles needed for the control to function properly:

``` html

```

Wrap an unordered list in a `div` with `draggable-grid` class:

``` html



    ...


```

Parameters of the control can be set via data attributes:

- `data-orientation` - `horizontal` or `vertical` orientation
- `data-span` - number of rows or columns (depends on orientation)
- `data-cell-size-ratio` - width to height ratio of the cell size
- `data-max-cell-size` - how much screen space a cell can occupy (`width height`, 0-1 values)

Import a JavaScript script:

``` html

```

Initialize the control when the page is loaded:

``` html

window.addEventListener("load", () => {
const draggableGridDivs = document.body.querySelectorAll("div.draggable-grid");

// Initialization of the control
for (const div of draggableGridDivs) {
DraggableGrid.initDraggableGridFor(div);
}
});

```

> For more advanced usage, see the [sample source code](index.html) or the [library source code](./src/DraggableGrid.js). The control's public API is accessible via methods without an underscore.