Tidak Ada Deskripsi

Z F e8af773bea 改成sider 7 tahun lalu
.vscode e1d2721a9d implement by using TS 7 tahun lalu
build bde0475a6a 更新新的算法,使得删除以后数据能绑定 7 tahun lalu
dist bde0475a6a 更新新的算法,使得删除以后数据能绑定 7 tahun lalu
docs e8af773bea 改成sider 7 tahun lalu
example ec5abcc41c 能够更新setstate item的数据 7 tahun lalu
src ec5abcc41c 能够更新setstate item的数据 7 tahun lalu
static ca57cee007 example移除src 7 tahun lalu
test 349dba365c 1.新增测试 7 tahun lalu
.babelrc 96cf668449 清除过期的垃圾 7 tahun lalu
.gitignore 60b27578b7 remove & ignore yarn.lock 7 tahun lalu
.prettierrc 81fd75713b 修改this.setstate在节点丢失以后还会继续更新bug 7 tahun lalu
LICENSE 9be956ea9a 新增readme ,mit协议 7 tahun lalu
README.EN.md 349dba365c 1.新增测试 7 tahun lalu
README.md 0bdb794d15 首页图片更新 7 tahun lalu
index.d.ts 8967942d6c 修改dragact版本 7 tahun lalu
index.js e6cd705469 更改入口配置 7 tahun lalu
package-lock.json 4763768088 更新github图标 7 tahun lalu
package.json 8967942d6c 修改dragact版本 7 tahun lalu
tsconfig.json ca57cee007 example移除src 7 tahun lalu
webpack.config.js e1d2721a9d implement by using TS 7 tahun lalu
webpack.pro.config.js e1d2721a9d implement by using TS 7 tahun lalu

README.EN.md

Whath is Dragact?

Dragact is a react component, which allows you to build your own dragable grid layout easily.

快速安装

npm install --save dragact

写一个例子🌰

import * as React from "react";
import * as ReactDOM from "react-dom";

import { Dragact } from 'dragact';
import './index.css'

ReactDOM.render(
    <Dragact
        col={8}
        width={800}
        margin={[5, 5]}
        rowHeight={40}
        className='plant-layout'
    >
        <div key={0} data-set={{ GridX: 0, GridY: 0, w: 4, h: 2 }} className='layout-child'>0</div>
        <div key={1} data-set={{ GridX: 0, GridY: 0, w: 1, h: 2 }} className='layout-child'>1</div>
        <div key={2} data-set={{ GridX: 0, GridY: 0, w: 3, h: 2 }} className='layout-child'>2</div>
    </Dragact>,
    document.getElementById('root')
);

Demo

Live Demo

Feature

  • auto sorted layout
  • mobile device supported
  • auto height fixed
  • static component
  • Draggable component

Dragact 提供的属性

interface DragactProps {
    layout?: DragactLayout[] //暂时不推荐使用
    /** 
     * 宽度切分比 
     * 这个参数会把容器的宽度平均分为col等份
     * 于是容器内元素的最小宽度就等于 containerWidth/col
    */
    col: number,

    /** 
     * 容器的宽度
    */
    width: number,

    /**容器内每个元素的最小高度 */
    rowHeight: number,

    /**
     * 容器内部的padding
     */
    padding?: number,

    children: any[] | any


    // 
    // interface GridItemEvent {
    //     event: any //浏览器拖动事件
    //     GridX: number //在布局中的x格子  
    //     GridY: number //在布局中的y格子  
    //     w: number //元素的宽度
    //     h: number //元素的高度
    //     UniqueKey: string | number //元素的唯一key
    // }

    /**
     * 拖动开始的回调
     */
    onDragStart?: (event: GridItemEvent) => void

    /**
     * 拖动中的回调
     */
    onDrag?: (event: GridItemEvent) => void

    /**
     * 拖动结束的回调
     */
    onDragEnd?: (key: number | string) => void

    /**
     * 每个元素的margin,第一个参数是左右,第二个参数是上下
     */
    margin: [number, number]

    /** 
     * layout的名字
    */
    className: number | string
}

Contribute

Want a new feature?

  1. If you have a feature request, please add it as an issue or make a pull request.
  2. After adding some awesome feature, please run the test and make sure it will pass all tests before you make a PR.

A bug?

If you have a bug to report, please reproduce the bug in Github issue with a sample code to help us easily isolate it.

TODO-LIST

  • horizontal swaping
  • resizing
  • touch handle
  • responsive layout
  • SSR/server rendering