折腾过程 react-beautiful-dnd 首页相遇的是 atlassian/react-beautiful-dnd,但是这个库已经进入维护状态,基本不更新了,在 React 18 严格默认下使用 hello-pangea/dnd: Beautiful and accessible drag and drop for lists with React. dnd 是基于前者的,所以 API 完全通用,找到的 react-beautiful-dnd Support lists with wrapping rows (Grid layout) · Issue #316 · atlassian/react-beautiful-dnd dnd kit 新发现
「github:」 https://github.com/madrobby/scriptaculous 6. react-beautiful-dnd 漂亮,可移植性 列表拖拽库. 「react-beautiful-dnd」 是为垂直和水平列表专门构建的更高级别的抽象. 在该功能的子集内「react-beautiful-dnd」提供强大,自然和美丽的拖放体验. 「github:」 https://github.com/atlassian/react-beautiful-dnd 「demo地址:」 https://react-beautiful-dnd.netlify.app
最流行的几个是:react-beautiful-dnd 脱颖而出,是最常用的,它提供了一个干净且高级的API,具有很多抽象。它是由Atlassian开发的。 问题**在epilot,我们在应用程序的不同部分广泛使用了react-beautiful-dnd。然而,在尝试一些复杂的场景时,我们在某些情境中遇到了一些障碍,它无法准确预测元素的放置位置。 react-beautiful-dnd停止维护和支持也不利于继续使用它的理由。解决方案最终,我们决定探索能够以更明确、直观和简单的API解决问题的替代库。 在react-beautiful-dnd中实现这一点可能会很具有挑战性,因为它将具有有限的功能并且需要大量的JavaScript来达到令人满意的状态。
「github:」 https://github.com/madrobby/scriptaculous 6. react-beautiful-dnd 漂亮,可移植性 列表拖拽库. 「react-beautiful-dnd」 是为垂直和水平列表专门构建的更高级别的抽象. 在该功能的子集内「react-beautiful-dnd」提供强大,自然和美丽的拖放体验. 「github:」 https://github.com/atlassian/react-beautiful-dnd 「demo地址:」 https://react-beautiful-dnd.netlify.app
接下来分享一个具体的拖拽式UI生成器示例代码,使用React和React-Beautiful-Dnd库实现,如下所示:import React, { useState } from 'react'; import { DragDropContext, Droppable, Draggable } from 'react-beautiful-dnd'; const components = [ { id: 具体如下所示:import React, { useState } from 'react'; import { DragDropContext, Droppable, Draggable } from 'react-beautiful-dnd
接下来我们看看主要要实现的功能点: 纯前端实现图片上传和预览 基于react-beautiful-dnd实现元素自由拖动排序 使用javascript实现生成uuid的函数 使用file-saver实现前端下载文件 使用react-beautiful-dnd实现元素自由拖动排序 大家在研究过H5-Dooring | 一款强大的开源H5编辑器 后就会发现react-dnd这个模块很熟悉, 因为该开源编辑器就使用了react-dnd 笔者在社区又发现了一个比较有意思的拖拽库react-beautiful-dnd, 同样可以实现优雅平滑的智能拖拽效果, 基本案例如下: 在深入研究该库之后笔者发现可以直接用来实现图片组件的拖拽并排序的功能
现在的组件库以及很成熟,我们可以跟据现有的组件库,例如antd、echarts二次封装成工作中用到的业务组件 // antd基础组件 npm install antd -S // 拖拽组件库 npm install react-beautiful-dnd
知识点抢先看 给看板添加拖拽功能 讲解 HTML5 中的 drop 和 drag 一、给看板添加拖拽功能 这一篇文章就只讲一个部分,正如标题所说,添加一个拖拽功能 实现效果像这样 我们实现这个功能采用了一个 react-beautiful-dnd 被拖数据是被拖元素的 id ("drag1") 把被拖元素追加到放置元素(目标元素)中 (参考于菜鸟教程) 可以亲自试一试:在线演示 总结 大概了解了一下如何使用 react-beautiful-dnd
taro: Taro脚手架 vue-cli: Vue脚手架 组件 ant-motion: React动画引擎 prop-types: React组件参数验证 react-amap: React地图组件 react-beautiful-dnd
实现要点:使用前端拖拽库(react-beautiful-dnd 或 dnd-kit)。后端写入时用乐观锁或版本号(避免并发覆盖)。每次状态变化记录事件(audit trail)。 六、、前端实现参考下面是一个简化的看板组件思路,使用 react-beautiful-dnd。 ' } }6.2 看板组件(关键片段)import React from 'react';import { DragDropContext, Droppable, Draggable } from 'react-beautiful-dnd
三、已有拖拽库 目前主流的拖拽库有: react-dnd: https://github.com/react-dnd/react-dnd/ react-beautiful-dnd: https://github.com /atlassian/react-beautiful-dnd/ sortablejs: https://sortablejs.github.io/Sortable/ react-sortable-hoc
react-beautiful-dnd 漂亮,可移植性 列表拖拽库 react-dnd 可帮助我们构建复杂的拖放界面,同时保持组件的分离 react-moveable 支持自由拖拽, 缩放, 参考线的灵活强大的拖拽库
通过它可以快速完成支持多人视频、语音、白板互动、录制回放等功能的在线教室 地址:https://github.com/netless-io/flat 17、react-beautiful-dnd:漂亮易用的 React 列表拖拽库 地址:https://github.com/atlassian/react-beautiful-dnd PHP 项目 18、icon-workshop:移动应用图标生成工具。
npm install react-beautiful-dnd # 或者 yarn add react-beautiful-dnd https://github.com/atlassian/react-beautiful-dnd
给出技术选型建议(如:推荐 dnd-kit vs react-beautiful-dnd) 输出结构化实施步骤 支持 快速回复模式(每行一个答案): dnd-kit yes - what kind of
这个示例(https://github.com/atlassian/react-beautiful-dnd)对理解拖放API(https://developer.mozilla.org/en-US/docs
react-accessibility:用于添加常见辅助功能控件的自定义组件 Live-Region:向屏幕阅读器用户发送消息的助手 react-beautiful-dnd-migration:支持从 react-beautiful-dnd 服务端渲染时长 服务端渲染时长差 Baseline (no drag and drop) +0ms +0ms 11.2ms +0ms react-beautiful-dnd
实现建议:前端使用虚拟化列表 + 轻量拖拽库(react-beautiful-dnd / dnd-kit)。后端设计轻量接口支持局部加载(卡片列表先只传摘要,详情页再加载附件与长文本)。 6.1 看板关键组件import React from 'react';import { DragDropContext, Droppable, Draggable } from 'react-beautiful-dnd
需要手动安装一下对应的依赖:"peerDependencies": { "@ant-design/icons": "^4.6.4", "antd": "^4.12.0", "react": "^17.0.0", "react-beautiful-dnd
拖拽库比较:对比Pragmatic Drag and Drop与其他流行的拖拽库(如react-beautiful-dnd、react-dnd等)。分析各自的优缺点和适用场景。