Sign in

    dndkit

    A MoonBit drag-and-drop toolkit based on the dnd-kit interaction engine.

    drag
    drop
    sortable
    collision
    Download zip
    Version
    0.1.0
    License
    MIT
    Last updated
    8 hours ago
    Downloads
    1

    #dndkit

    MoonBit 里的拖放工具箱,移植自 dnd-kit 当前主线的交互引擎:几何、碰撞、拖放会话、修饰器、DOM 传感器和排序。

    MoonBit 里已有的几何库和刚体碰撞库不负责「按住、移动、松开、重排」。这个模块补的是那一层。更完整的对照写在 docs/necessity.md。

    #安装

    工具链使用仓库根目录 .moonbit-version 中的版本(moonc v0.10.15+943464bfa)。

    moon add V1GreenSummer/dndkit

    发布到 mooncakes.io 之前,把 moon.mod 里的 username 换成发布者的用户名。

    #用法

    矩形相交和激活距离可以直接调用:

    ///|
    test {
    let rect = @geometry.Rectangle::new(0.0, 0.0, 10.0, 10.0)
    inspect(
    rect.intersection_area(@geometry.Rectangle::new(5.0, 5.0, 10.0, 10.0)),
    content="25",
    )
    inspect(
    @geometry.exceeds_distance(
    @geometry.Point::{ x: 3.0, y: 4.0, },
    @geometry.Scalar(4.0),
    ),
    content="true",
    )
    }

    #示例

    构建 JS 后端,然后用浏览器打开 example/index.html。页面里的三行可以用指针上下拖动,顺序由 array_move 计算。

    moon build --target js

    打开 example/index.html。

    Source Files