本文介绍了Extjs 3.x:可以让面板还是容器移动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have an Ext.Container and I need to add to it a user-movable object.

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

I see elsewhere that an Ext.Window is not supposed to be nested into objects, thus what are my options regarding other movable Ext objects?

关于Casper

推荐答案

回到这个问题,你的建议帮助我。面向面板的 ExtJS 文档建议如何执行可拖放自定义实现。

Returning to this problem, your suggestions helped me along the way. The ExtJS documentation for a panel suggest how to do a custom implementation of draggable.

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

在我的项目中,我需要一个容器内的可拖动元素元素,所以我需要做一些额外的事情。

为什么?
因为在浏览器窗口空间中完成检索任何位置信息,并且设置位置似乎是在>父空间。因此,我需要在设置最终面板位置之前翻译该位置。

In my project, I needed draggable elements inside a container element, thus I needed to do something extra.
Why?Because retrieving any position information is done in browser-window-space and setting the position seems to be in parent-space. Thus I needed to translate the position before setting the final panel position.

//  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);
    }
}

希望这可以帮助别人,再次感谢为您的输入:)

I hope this can help others and again thanks a lot for your inputs :)

这篇关于Extjs 3.x:可以让面板还是容器移动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 06:41