javascript - Extjs 3.x : Can I make a panel or a container movable?

标签 javascript extjs object movable

我有一个 Ext.Container,我需要向它添加一个用户可移动的对象。

我看到 elsewhere Ext.Window 不应该嵌套到对象中,因此对于其他可移动的 Ext 对象我有什么选择?

问候,卡斯珀

最佳答案

回到这个问题,你的建议一路帮助了我。 面板ExtJS 文档建议如何自定义 可拖动 实现。

draggable: {
//  Config option of Ext.Panel.DD class.
//  It's a floating Panel, so do not show a placeholder proxy in the original position.
    insertProxy: false,

//  Called for each mousemove event while dragging the DD object.
    onDrag : function(e){
//      Record the x,y position of the drag proxy so that we can
//      position the Panel at end of drag.
        var pel = this.proxy.getEl();
        this.x = pel.getLeft(true);
        this.y = pel.getTop(true);

//      Keep the Shadow aligned if there is one.
        var s = this.panel.getEl().shadow;
        if (s) {
            s.realign(this.x, this.y, pel.getWidth(), pel.getHeight());
        }
    },

//  Called on the mouseup event.
    endDrag : function(e){
        this.panel.setPosition(this.x, this.y);
    }
}

在我的项目中,我需要容器元素内的可拖动元素,因此我需要做一些额外的事情。
为什么? 因为检索任何位置信息都是在 browser-window-space 中完成的,而设置位置似乎是在 parent-space 中。因此我需要在设置最终面板位置之前转换位置。

//  Called on the mouseup event.
endDrag: function (e) {
    if (this.panel.ownerCt) {
        var parentPosition = this.panel.ownerCt.getPosition();
        this.panel.setPosition(this.x - parentPosition[0], this.y - parentPosition[1]);
    } else {
        this.panel.setPosition(this.x, this.y);
    }
}

我希望这可以帮助其他人,再次非常感谢您的投入:)

关于javascript - Extjs 3.x : Can I make a panel or a container movable?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3108958/

相关文章:

javascript - 使用 WebMIDI API 发送 MIDI 调音请求会导致错误

javascript - Ajax post发送嵌套数组,未定义

javascript - ExtJs4 - 动态加载网格列?

extjs - 在 View 和 View Controller 之间继承的 MVVM

javascript - 仅当我从主页启动流程时组件才会呈现

javascript - 找不到 ng-click 函数中的参数

javascript - 根据滚动方向切换移动导航

javascript - 使用 ext js 框架访问元素的 get、select 和 query

java - 使用用户输入创建新对象 [JAVA]

javascript - 如何在 JavaScript 中克隆静态类?