gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 07:06:36 24 4
gpt4 key购买 nike

我有一个 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com