Comments (14)
@FailLone 更新了一个新版本,你可以尝试npm update一下,看看还有没有问题。主要修改了两个地方:
/**
* 拖动开始的回调
*/
onDragStart?: (event: GridItemEvent, currentLayout: DragactLayoutItem[]) => void
/**
* 拖动中的回调
*/
onDrag?: (event: GridItemEvent, currentLayout: DragactLayoutItem[]) => void
/**
* 拖动结束的回调
*/
onDragEnd?: (event: GridItemEvent, currentLayout: DragactLayoutItem[]) => void
第二个地方就是这个
this.setState({})
的问题。
from dragact.
@FailLone 已经添加了,增加和删除逻辑的支持。
建议
- 更新dragact到最新版本
- 暂时别关这个issue
- 如果做好了,有兴趣可以把代码给我,我做成awesome-demo
多谢
from dragact.
@FailLone 能否将你写的代码post上来,我看看,多谢。
from dragact.
@FailLone
2. 此后getLayout api拿到的layout中B的信息是就旧的
这个是已经知道的bug,我已经修改。
- 第一个问题我还没找到,请麻烦提供一个实现。多谢。
from dragact.
@FailLone 预期需要调用getLayout,我现在在事件回掉中,加入了新的参数,以获得全局的layout
/**
* 拖动开始的回调
*/
onDragStart?: (event: GridItemEvent, currentLayout: DragactLayoutItem[]) => void
/**
* 拖动中的回调
*/
onDrag?: (event: GridItemEvent, currentLayout: DragactLayoutItem[]) => void
/**
* 拖动结束的回调
*/
onDragEnd?: (event: GridItemEvent, currentLayout: DragactLayoutItem[]) => void
第二个参数就是当前的layout.
from dragact.
@215566435
onDragEnd = () => {
this.props.onLayoutChange(compact(this.dragact.getLayout().map(
v => {
if (v.payload.key === this.target.payload.key) {
return {...v, payload: [v.payload, this.dragWhich.payload]}
}
if (v.payload.key === this.dragWhich.payload.key) {
return null
}
return v
}
)))
}
from dragact.
@215566435 入口文件路径忘改了~
from dragact.
@FailLone 修改了
from dragact.
@215566435 css文件缺失
from dragact.
很抱歉又打扰了。问题还是没有解决。
我所说的
2、此后getLayout api拿到的layout中B的信息是旧的
不仅仅是指布局信息,还有子组件需要的信息。这种情况在增删子组件的同时修改子组件信息都会出现。
原因是:Dragact组件在componentWillReceiveProps中处理nextProps时,将增删改三步分离开来,即默认增删的同时不会修改。
componentWillReceiveProps(nextProps: any) {
if (this.props.layout.length > nextProps.layout.length) { //remove
const mapLayoutCopy = { ...this.state.mapLayout };
nextProps.layout.forEach((child: any) => {
if ((mapLayoutCopy as any)[child.key + ''] !== void 666) delete (mapLayoutCopy as any)[child.key + ''];
})
for (const key in mapLayoutCopy) {
const newLayout = this.state.layout.filter((child) => {
if (child.key + '' !== key + '') return child
})
const { compacted, mapLayout } = compactLayout(newLayout, undefined, this.state.mapLayout);
this.setState({
containerHeight: getMaxContainerHeight(compacted, this.props.rowHeight, this.props.margin[1], this.state.containerHeight),
layout: compacted,
mapLayout
})
}
} else if (this.props.layout.length < nextProps.layout.length) {//add
var item;
for (const idx in nextProps.layout) {
const i = nextProps.layout[idx];
from dragact.
@FailLone l了解了,不好意思,我稍微有点欠缺考虑了这一部分,增加删除的逻辑。明天上班的时候我会进行修改。
from dragact.
@FailLone 可以邮件一份代码给我看看,我这样好调试一些。多谢。[email protected]
from dragact.
@FailLone 已经清除bug在何处,晚点时间可以修改。
from dragact.
@FailLone 明天就可以出个船新版本,已经了解bug在哪里了。
from dragact.
Related Issues (20)
- 希望以后能够支持在容器随意拖动元素,而不是往上挤,像安卓手机的图标那样
- click事件与move事件重叠
- 控件可以拖动互相重叠,然后点击下面被覆盖的控件让其放在最前端显示吗? HOT 1
- English Doc? HOT 1
- 拖拽过来的元素大小可调节,怎么限制可调节范围
- this.props.children缺少判断
- 自由度不够 无法任意层级嵌套使用
- 全部删除报错 HOT 1
- demo 挂了
- 当子项足够大时无法缩小
- 拖动到外面后,如果数据变化,布局会出错 HOT 1
- setState会引起重排
- 支持IE8+么?
- dragact
- dragact安装后,和antd的index样式冲突,页面布局错乱,antd按钮组件样式失效问题怎么解决 HOT 1
- 在antd pro中使用dragact导致antd样式部分失效,估计原因是因为把 umi 的 css merge 给挂掉了,请问能否帮忙修复该问题 @Foveluy HOT 2
- 报错了
- Table固定的列有没有components属性
- node v9.11.2 版本下报错
- 当内容全部删除的时候,报错:Cannot read properties of undefined (reading 'GridY')
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dragact.