Element Draggable

A lightweight draggable library.

Tento skript by nemal byť nainštalovaný priamo. Je to knižnica pre ďalšie skripty, ktorú by mali používať cez meta príkaz // @require https://update.greasyfork.org/scripts/587662/1879553/Element%20Draggable.js

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey, Greasemonkey alebo Violentmonkey.

Na inštaláciu tohto skriptu je potrebné nainštalovať rozšírenie, ako napríklad Tampermonkey.

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey, % alebo Violentmonkey.

Na nainštalovanie skriptu si budete musieť nainštalovať rozšírenie, ako napríklad Tampermonkey alebo Userscripts.

Na inštaláciu tohto skriptu je potrebné nainštalovať rozšírenie, ako napríklad Tampermonkey.

Na inštaláciu tohto skriptu je potrebné nainštalovať rozšírenie správcu používateľských skriptov.

(Už mám správcu používateľských skriptov, nechajte ma ho nainštalovať!)

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie, ako napríklad Stylus.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

Na inštaláciu tohto štýlu je potrebné nainštalovať rozšírenie správcu používateľských štýlov.

(Už mám správcu používateľských štýlov, nechajte ma ho nainštalovať!)

Autor
ryxel
Verzia
1.0
Vytvorené
19.07.2026
Aktualizované
19.07.2026
Veľkosť
6,3 KB
Licencia
MIT

Draggable

A JavaScript library for dragging elements, usable in Tampermonkey scripts or regular web pages.

Usage

const element = document.querySelector('#element');
const handle = document.querySelector('#handle');

const options = {
    handle: handle,
    savePosition: true,
    id: 'example'
};

const drag = new Draggable(element, options);

Parameters

  • element (HTMLElement): The target DOM element to be dragged.
  • options (Object, optional): Configuration object.

Options Configuration

Parameter Type Default Description
handle HTMLElement element Specifies the drag handle.
savePosition boolean false Whether to save the element position.
id string null Unique identifier used for saving the position. Only works when savePosition is true.

Notes

  • A unique id must be provided when position saving is enabled.
  • When using in a Tampermonkey script, if position saving is enabled, it is recommended to declare the following permissions in the script header:
// @grant GM_getValue
// @grant GM_setValue

With these permissions, position data will be stored through the userscript manager and can persist across pages.

If the permissions are not declared, position data will be stored in the current page's localStorage.

Destroy Instance

When the dragging functionality is no longer needed or the element is removed, the instance should be manually destroyed to release resources and remove event listeners.

drag.destroy();