1 unstable release

0.1.0 Jan 10, 2021

#944 in WebAssembly

Download history 12/week @ 2024-03-09 3/week @ 2024-03-16 21/week @ 2024-03-30 9/week @ 2024-04-06 12/week @ 2024-04-13 2/week @ 2024-04-27 23/week @ 2024-05-18 40/week @ 2024-05-25 51/week @ 2024-06-01 114/week @ 2024-06-08 97/week @ 2024-06-15 42/week @ 2024-06-22

323 downloads per month

MIT license

64KB
888 lines

Dragula-rs

GitHub GitHub Workflow Status

Drag and drop so simple it hurts

Wrapper for the Dragula Javascript library.

Usage

Dragula provides the easiest possible API to make drag and drop a breeze in your applications.

use dragula::*;

let doc = web_sys::window().unwrap().document().unwrap();
let element = doc.get_element_by_id("drag-container").unwrap();

let drake = dragula(&[element]);

You can also provide an Options instance to specify behaviour of certain drag-and-drop features.

use dragula::*;
use dragula::options::Direction;
use web_sys::Element;

//--snip--

let options = Options {
    is_container: Box::new(|el| {
        Element::from(el).class_list().contains("drag-container")
    }),
    direction: Direction::Horizontal,
    revert_on_spill: true,
    ..Options::default()
};

let drake = dragula_options(&[element], options);

//--snip--

cargo Features

  • js-sys: On by default. Can be used to toggle dependencies on the js-sys crate. Most of this crate relies solely on wasm-bindgen, so disabling this feature currently just prevents you from getting containers on an existing Drake. The main reason you might want to disable this would be to improve compile times.

Dependencies

~1–1.7MB
~31K SLoC