Giter VIP home page Giter VIP logo

Comments (14)

Foveluy avatar Foveluy commented on May 25, 2024 1

@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.

Foveluy avatar Foveluy commented on May 25, 2024 1

@FailLone 已经添加了,增加和删除逻辑的支持。

建议

  1. 更新dragact到最新版本
  2. 暂时别关这个issue
  3. 如果做好了,有兴趣可以把代码给我,我做成awesome-demo

多谢

from dragact.

Foveluy avatar Foveluy commented on May 25, 2024

@FailLone 能否将你写的代码post上来,我看看,多谢。

from dragact.

Foveluy avatar Foveluy commented on May 25, 2024

@FailLone
2. 此后getLayout api拿到的layout中B的信息是就旧的

这个是已经知道的bug,我已经修改。

  1. 第一个问题我还没找到,请麻烦提供一个实现。多谢。

from dragact.

Foveluy avatar Foveluy commented on May 25, 2024

@FailLone 预期需要调用getLayout,我现在在事件回掉中,加入了新的参数,以获得全局的layout

    /**
     * 拖动开始的回调
     */
    onDragStart?: (event: GridItemEvent, currentLayout: DragactLayoutItem[]) => void

    /**
     * 拖动中的回调
     */
    onDrag?: (event: GridItemEvent, currentLayout: DragactLayoutItem[]) => void

    /**
     * 拖动结束的回调
     */
    onDragEnd?: (event: GridItemEvent, currentLayout: DragactLayoutItem[]) => void

第二个参数就是当前的layout.

from dragact.

FailLone avatar FailLone commented on May 25, 2024

@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
        }
    )))
}

image

image

from dragact.

FailLone avatar FailLone commented on May 25, 2024

@215566435 入口文件路径忘改了~

from dragact.

Foveluy avatar Foveluy commented on May 25, 2024

@FailLone 修改了

from dragact.

FailLone avatar FailLone commented on May 25, 2024

@215566435 css文件缺失

from dragact.

FailLone avatar FailLone commented on May 25, 2024

很抱歉又打扰了。问题还是没有解决。

我所说的

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.

Foveluy avatar Foveluy commented on May 25, 2024

@FailLone l了解了,不好意思,我稍微有点欠缺考虑了这一部分,增加删除的逻辑。明天上班的时候我会进行修改。

from dragact.

Foveluy avatar Foveluy commented on May 25, 2024

@FailLone 可以邮件一份代码给我看看,我这样好调试一些。多谢。[email protected]

from dragact.

Foveluy avatar Foveluy commented on May 25, 2024

@FailLone 已经清除bug在何处,晚点时间可以修改。

from dragact.

Foveluy avatar Foveluy commented on May 25, 2024

@FailLone 明天就可以出个船新版本,已经了解bug在哪里了。

from dragact.

Related Issues (20)

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.