javascript - 如何在 extJs 或 javascript 中制作可交换组件

标签 javascript html extjs extjs6

如何在 exJs 或 javascript 中制作可交换组件。

我有两个组件,都可以拖动。

            xtype : "panel",
            title: 'My Apps',
            region: 'east',
            width: 290,
            items:[{
                xtype : 'panel',
                cls: 'myCLS',
                iconCls : 'app-info-appstore',
                title: 'Home',
                draggable : true,
                html : 'Home.',
                listeners: {
                    'render': function(panel) {
                        panel.body.on('click', function() {
                            alert('onclick');
                        });
                     }
                 }
                
            },{
                xtype : 'panel',
                cls: 'myCLS',
                title: 'Profile',
                iconCls : "app-info-iconToure",
                draggable : true,
                html : 'Apps',
            }

当我将一个拖到另一个时,它会重叠。我们如何在 extJS 中交换两个元素的位置。

任何其他图书馆帮助也将有效。

最佳答案

onDrop 你通过 insert 将它添加到父容器中.

要获得正确的位置,您可以根据鼠标位置计算它或...

onDrop 你得到你当前所在的目标 dom 元素。

const extComponent = Ext.ComponentManager.from(domEl),
      currentIndex = ... // search for the position of that item in parent

parent.insert(droppedItem, currentIndex);

进一步的工作

  • 如果您使用占位符代理,您甚至可以预览这些内容。
  • 如果组件大小相同,请使用 snap。

示例

Fiddle

关于javascript - 如何在 extJs 或 javascript 中制作可交换组件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70001812/

相关文章:

javascript - 咕噜声 : how to generate jshint output as HTML

javascript - 什么会导致 document.ready 函数为空?

javascript - 带有复制或移动图标的树拖放

extjs网格过滤日期范围

css - 未捕获的语法错误 : Invalid or unexpected token @import css

javascript - 如何将单选按钮更改为 Bootstrap 按钮

javascript - 从外部js文件获取模板变量的最佳方式

HTML5 音频控制停止按钮(相对于暂停)

javascript - 我如何通过网站在移动设备的WhatsApp上共享图像

javascript - 从 node_modules 导入 JS 到 Vue