ext desktop shortcuts 自动排列

本文讨论了在UI设计中遇到图标无法自动排列的问题,并通过修改desktop.js实现自动排列功能,包括设置按钮高度、宽度、间距以及计算列数和行数,以确保布局的合理性和美观性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

昨天改ui时碰到的问题。
图标不能自动排列。

修改desktop.js,添加到最后



//自动排列
var btnHeight = 61;
var btnWidth = 64;
var btnPadding = 15;
var col = null;
var row = null;

function initColRow(){
col = {index: 1, x: btnPadding};
row = {index: 1, y: btnPadding};
}

initColRow();

function isOverflow(y){
var h=Ext.lib.Dom.getViewHeight()-taskbarEl.getHeight();
if(y > h){
return true;
}
return false;
}

this.setXY = function(item){
var bottom = row.y + btnHeight,
overflow = isOverflow(row.y + btnHeight);

if(overflow && bottom > (btnHeight + btnPadding)){
col = {
index: col.index++
, x: col.x + btnWidth + btnPadding
};
row = {
index: 1
, y: btnPadding
};
}

Ext.fly(item).setXY([
col.x
, row.y
]);

row.index++;
row.y = row.y + btnHeight + btnPadding;
};

this.handleUpdate = function(){
initColRow();
//var items=shortcuts.dom.children;
var items=Ext.query("dt",shortcuts.dom);
for(var i = 0, len = items.length; i < len; i++){
this.setXY(items[i]);
}
}
this.handleUpdate();
Ext.EventManager.onWindowResize(this.handleUpdate, this, {delay:500});
//end shortcuts 自动换行
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值