/draggable

A plugin to make every element can be draggable with mouse,you can set the axis, area.

Primary LanguageTypeScriptMIT LicenseMIT

A simple plugin make your html element draggable!

repertory

Demo

  • Install

NPM

$npm install kaguya-draggable

or

<script src="./../dist/draggable.js"></script>
  • API
key value description
selector '.drag' the root node
axis 'both'/'x'/'y' draggable axis
cursor 'move' the cursor style of selector
userSelect boolean userSelect of element
callback function get the coordinate
    const drag = new Draggable({
        selector: '#drag',
        axis: 'both',
        userSelect: false,
        cursor: 'move',
        callback: (data) => {
            console.log(data);
        },
    });

or you can register nodelist by pass class or element selector

    const drag = new Draggable({
        selector: '.drag',
        axis: 'both',
        cursor: 'move',
    });

contribute is welcome, if you want to contribute code view CONTRIBUTING