# j-Movable

> Komponent ovláda podobný preťahovateľný prvok a podporuje pohyb medzi sebou. Každý prvok podľa selektora musí mať definovaný atribút draggable='true'.

Framework: jcomponent20
Product: jComponent 20 (jcomponent@20)
Language: sk
Content-SHA256: 5a18c9cc024e1342a601df1a5e6892b57aac493cd1b844df0ad6d4113d9c03f7
Snapshot: c0700e321579725c5cf4f5ace1ad7d2866d1b4f93c24a63c0b41b6b7998e976c
Sources: components@910ed1a86f6e72b4f031d3ad0dc7844f9fc5cb8e
Review: not-recorded

Komponent zvláda podobný prvok `draggable` a podporuje pohyb medzi sebou. Každý prvok podľa selektora musí mať definovaný atribút `draggable="true"`.


__Konfigurácia__:

- Selektor jQuery `selector {String}` na sledovanie
- `exec {String}` Cesta k metóde, ktorá sa vykoná, ak používateľ presunie prvok
- Udalosti drag & drop `global {Boolean}` budú spojené s `document` (predvolené: `false`)
- Selektor `parent {String}` na nájdenie prvku, na ktorý sa budú viazať obaly drag & drop (predvolené: aktuálny prvok)
- `move {Boolean}` umožňuje automatické preobjednávanie prvkov (predvolené: `true`)
- `container {String}` volič pre nájdenie hlavného kontajnera
- __NOVINKA__ `check {Function(el)}` voliteľná, funkcia na kontrolu ťahateľnosti (musí vrátiť `true` alebo `false`)

__Príklad metódy `Exec`__:

```javascript
function exec_method(list, dragged, target) {
	// @list jQuery list
}
```

__Je dobré vedieť__:

- `path` vykonáva `CHANGE()`

Použite ho so `<ui-component name="movable">`. Keď komponent ešte nie je načítaný, jComponent ho stiahne pri prvom použití z adresy v `DEF.fallback` (predvolene CDN Componentator). Autor: Peter Širka. Zdroj: úložisko komponentov Componentator, licencia MIT.

```html example.html
<ui-component name="movable" config="selector:.dragme;exec:moved">
	<div class="dragme" draggable="true" style="width:50px;line-height:50px;background-color:#F0F0F0;text-align:center;position:relative;display:inline-block;margin:10px">A</div>
	<div class="dragme" draggable="true" style="width:50px;line-height:50px;background-color:#E0E0E0;text-align:center;position:relative;display:inline-block;margin:10px">B</div>
	<div class="dragme" draggable="true" style="width:50px;line-height:50px;background-color:#D0D0D0;text-align:center;position:relative;display:inline-block;margin:10px">C</div>
	<div class="dragme" draggable="true" style="width:50px;line-height:50px;background-color:#C0C0C0;text-align:center;position:relative;display:inline-block;margin:10px">D</div>
	<div class="dragme" draggable="true" style="width:50px;line-height:50px;background-color:#B0B0B0;text-align:center;position:relative;display:inline-block;margin:10px">E</div>
	<div class="dragme" draggable="true" style="width:50px;line-height:50px;background-color:#A0A0A0;text-align:center;position:relative;display:inline-block;margin:10px">F</div>
</ui-component>

<script>
	function moved(list) {
		console.log(list);
	}
</script>
```
