Giter Site home page Giter Site logo

foveluy / dragact Goto Github PK

View Code? Open in Web Editor NEW
764.0 23.0 189.0 27.5 MB

a dragger layout system with React style .

License: MIT License

JavaScript 4.16% CSS 1.49% HTML 0.31% TypeScript 94.04%
react reactjs drag-and-drop drag-drop draggable grid grid-layout grid-system sortable sortable-lists

dragact's Introduction

特别声明

由于本人正在忙其他的事情,dragact 已经暂停维护了。请不要使用 dragact(出了问题我实在没精力帮您解决,实在抱歉

最后,我推荐的替换是:

上述两个都是非常优秀的开源项目,请大家自行选择。

Dragact 👋

npm version npm downloads

Dragact 是一款 React 组件,他能够使你简单、快速的构建出一款强大的 拖拽式网格(grid)布局.

Demo 地址 ✌️

Live Demo(预览地址)

特点

  • 自动布局的网格系统
  • 手机上也可以操作
  • 高度自适应
  • 静态组件
  • 拖拽组件
  • 自动缩放组件
  • 自定义拖拽把手
  • 自定义缩放把手
  • 响应式布局

快速开始

官方文档

ChangeLog

v0.2.8

  • 版本跳跃
  • 添加增加 add/remove 布局
  • 新增记忆布局 demo
  • 更新 col,width,rowHeight 以后,会动态进行更新
  • [fix]修复更新数据视图内部不更新的 bug

v0.1.7

  • 优化性能-使用 reselect 的原理
  • 拖拽手感优化
  • 优化 dom 的层级
  • 自定义拖拽把手和 resize 把手
  • 拓展了 child 的渲染方式

v0.1.6

  • 修正 zIndex 的错误
  • 新增拖拽把手
  • 自由选择拖拽和 resize
  • 添加删除逻辑
  • 修改成 child 渲染方式
  • placeholder 选择

v0.1.3

  • 新增组件 api:getLayout,用于获取当前的 layout.
  • 新增组件的 resize

测试

git clone https://github.com/215566435/Dragact.git
cd Dragact
npm install
npm run test

贡献

想要一个新的特色、功能?

  1. 如果你想添加一些新功能或者一些非常棒的点子,请发起 issue 告诉我,谢谢!
  2. 如果你已经阅读过源代码,并且添加了一些非常牛 X🐂 的点子,请发起你的 PR.

有 bug?

如果你发现了本项目的 Bug,请务必马上告诉我。添加一个 issue,并且帮忙给出最最简单重现的例子,这能让我快速定位到 Bug 帮你解决,谢谢!

LICENSE

MIT

dragact's People

Contributors

emibcn avatar foveluy avatar leeeeeem avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dragact's Issues

求水平交换功能

类似支付宝首页-更多页里,编辑我的应用的交互方式,在插入到dropdown的位置,不影响其他组件的原来顺序

报错了

main.js?1552287600v47:39477 Uncaught TypeError: (0 , _typeof4.default) is not a function
这一行
var _typeof = typeof _symbol2.default === "function" && (0, _typeof4.default)(_iterator2.default) === "symbol" ? function (obj) {

How to run

在浏览器访问的时候,提示“Uncaught SyntaxError: Unexpected token *”
请教一下,这个库需要引入特殊的解释器么?

ts接口定义

<Dragact
col={8}
width={800}
margin={[5, 5]}
rowHeight={40}
className='plant-layout'
>报错
node_modules/dragact/src/lib/dragger/index.tsx
(377,17): Type 'string | number' is not assignable to type 'number'.
Type 'string' is not assignable to type 'number'.
是因为ts有一些接口定义不对么

Dragact嵌套图片问题

Dragact嵌套图片,图片宽高是100%,点击图片拖拽就出现BUG了
<Dragact className="plant-layout" //必填项 col={16} //必填项 layout={fakeData} //必填项 margin={[5, 5]} //必填项 placeholder //必填项 rowHeight={300} //必填项 style={{ background: '#333' }} //非必填项 width={800} > {(item, provided) => ( <div {...provided.props} {...provided.dragHandle} style={{ ...provided.props.style, ...getblockStyle(provided.isDragging), }} > {/*provided.isDragging ? '正在抓取' : '停放'*/} <img alt="" src="https://img.alicdn.com/imgextra/i3/1928865133/O1CN011nmxSUvVK566HsW_!!1928865133.jpg" style={{ width: "50px", height: "50px", }} /> </div> )} </Dragact>

babelrc 的一点点小建议

  1. 似乎 babel-preset-es2015 是一个比较过期的解决方案,也许可以考虑 babel-preset-env
    2.似乎可以考虑在默认的情况下不添加 react-hot-loader, transform-runtime,把这两个放在 test 和 webpack 两个 env 似乎比较适合;因为这两个会在 prod 的 bundle 中加入一些不必要的东西

下个月我可能会研究一下 rollup + ts 然后过来提 pr

有没有dragOver事件

我看到api中没有dragOver事件,现在有一种需求就是跟手机桌面app一样,有一些应用和大小不一的小部件,不想拖拽排版,这个插件可以满足,但是手机桌面还有一种是应用之间拖拽可以创建文件夹。
--------------------
看了下until里面的源码和React-Grid-Layout的源码,发现原来用的是碰撞检测。

保存布局重新加载后布局混乱

Demo界面的存储布局示例挂掉了,我按照LayoutRestor示例自己编写了一段代码进行测试,但是恢复布局后布局是错乱的,不是保存时的样子。

ie11兼容性问题

请问兼容ie11吗?这边ie11打开控制台报错,有什么解决方案

自由度不够 无法任意层级嵌套使用

BI图要实现这个随意拖放的效果 但是这个嵌套其实是比较深的 所以他并不一定是在children里面的 这就会导致你这个拖放的效果会导致整个布局出错 希望在这个基础上能独立出来一个item 让不管在哪一级 那一层都可以直接进行使用

在ie11浏览器上控制台报错

The above error occurred in one of your React components:
in div (at Dragact.js:43)
in Unknown
in Unknown
in div
in Unknown (at Dragact.js:27)
in Unknown (at App.js:48)
in div (at App.js:35)
in Unknown (at index.js:7)

Consider adding an error boundary to your tree to customize error handling behavior.
Visit https://fb.me/react-error-boundaries to learn more about error boundaries.

'use strict'
import React from 'react';

import {Dragact} from 'dragact'

import styles from './Dragact.scss';

class DragactDemo extends React.Component {
  constructor(props) {
    super(props);

  }

  getblockStyle = (isDragging) => {
    console.log("isDragging", isDragging)
    return {
      background: isDragging ? '#ccc' : 'wheat'
    }
  }

  getLayout = (item, provided) => {
    console.log('item', item, provided)
  };

  render() {
    return (
      <Dragact
        layout={fakeData}
        col={1}
        rowHeight={40}
        margin={[15, 5]}
        padding={10}
        className='plant-layout'
        style={{background: "rgb(247, 221, 255)"}}
        canResize={true}
        onDragEnd={(item, provided) => this.getLayout(item, provided)}
      >
        {(item, provided) => {
          const blockStyle = this.getblockStyle(provided.isDragging);
          const styleDiv = Object.assign({}, provided.props.style, blockStyle, {width: ` calc(100% - 30px)`});
          console.log('styleDiv', provided, blockStyle, styleDiv)
          return (
            <div {...provided.props} {...provided.dragHandle} style={styleDiv}>
              {provided.isDragging ? '正在抓取' : '停放'}{item.key}
            </div>
          )
        }}
      </Dragact>
    );
  }
}

export default DragactDemo;


const fakeData = [
  {GridX: 0, GridY: 0, w: 1, h: 2, key: "0"},
  {GridX: 0, GridY: 0, w: 1, h: 2, key: "1"},
  {GridX: 0, GridY: 0, w: 1, h: 2, key: "2"},
  {GridX: 0, GridY: 0, w: 1, h: 2, key: "3"},
];

求水平交换功能

看到了这个组件,很顺滑,但是子集貌似没有水平拖拽,都需要向下挤出一个单位的空间,这样需要操作两次,很难受

在dragend事件中修改layout的问题

想做一个拖拽merge两个子组件的东西,所以需要在dragend中修改layout。

假设拖拽A到B内,生成一个merge后的B。无非是移除layout 中的A,以及修改layout中的B。

这个时候存在两个问题:
1、react报一个在unmount的组件上调用setstate的警告
2、此后getLayout api拿到的layout中B的信息是就旧的

layout.map遍历出错

dragact.js文件 this.props中并没有layout属性,请问这个layout是做什么用的

English Doc?

I have seen some react-dnd libraries, and I really like the look and feel of the examples of this package, but: Language its a problem, is there a chance of an English doc for this repo?

区块能否绝对px 大小

您的这个插件和reacr-grid-layout 十分相似 都是栅格化网格布局 大致思路都是对外部进行分割成N列 这样的话等于说是按最外层百分比控制区块宽度 那么我现在有个疑问 能不能做成区块大小是固定的 比如说一个区块是400px*600px 那么外面的大小不影响区块的大小 外部最小宽度由内部区块最大宽度决定

全部删除报错

将全部的数据删除掉,layout中数据为[] 空数组的时候报错!大神解决一下呗

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.