No Description

Z F 756b57ad23 update dock version 7 years ago
.vscode e1d2721a9d implement by using TS 7 years ago
build 072648347b [build]0.2.8 7 years ago
dist 072648347b [build]0.2.8 7 years ago
docs 756b57ad23 update dock version 7 years ago
example ec5abcc41c 能够更新setstate item的数据 7 years ago
src f76118812e 开启硬件加速 7 years ago
static f8cb7e948d 更新[0.2.8] 7 years ago
test 349dba365c 1.新增测试 7 years ago
.babelrc 96cf668449 清除过期的垃圾 7 years ago
.gitignore 60b27578b7 remove & ignore yarn.lock 7 years ago
.prettierrc 81fd75713b 修改this.setstate在节点丢失以后还会继续更新bug 7 years ago
LICENSE 9be956ea9a 新增readme ,mit协议 7 years ago
README.EN.md 349dba365c 1.新增测试 7 years ago
README.md 8e4adc5b2d 更新readme 7 years ago
index.d.ts 8967942d6c 修改dragact版本 7 years ago
index.js e6cd705469 更改入口配置 7 years ago
package-lock.json 756b57ad23 update dock version 7 years ago
package.json 756b57ad23 update dock version 7 years ago
tsconfig.json ca57cee007 example移除src 7 years ago
webpack.config.js e1d2721a9d implement by using TS 7 years ago
webpack.pro.config.js e1d2721a9d implement by using TS 7 years ago

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