javascript - 'autoposition' 属性未在 JsPanel 之间应用
问题描述
我开始在工作项目中使用JsPanel,我对为什么在某些面板之间没有应用“自动定位”有些疑问。
我有 4 个面板:A、B、C 和 D。
面板:
jsPanel.create({
id: 'A',
theme: 'primary',
headerTitle: 'A panel',
position: { my: 'left-top',
at: 'left-top',
offsetX: '0px',
offsetY: '0px',
autoposition: 'down'
},
contentSize: '450 250',
content: '<p> Test test test</p>',
callback: function () {
this.content.style.padding = '20px';
},
onbeforeclose: function () {
return confirm('Are you sure?');
}
});
B面板:
jsPanel.create({
id: 'B',
theme: 'primary',
headerTitle: 'B panel',
position: { my: 'center-top',
at: 'center-top',
offsetX: '0px',
offsetY: '0px',
autoposition: 'down'
},
contentSize: '450 250',
content: '<p> Test test test</p>',
callback: function () {
this.content.style.padding = '20px';
},
onbeforeclose: function () {
return confirm('Are you sure?');
}
});
C面板:
jsPanel.create({
id: 'C',
theme: 'primary',
headerTitle: 'C panel',
position: { my: 'right-top',
at: 'right-top',
offsetX: '0px',
offsetY: '0px',
autoposition: 'down'
},
contentSize: '450 250',
content: '<p> Test test test</p>',
callback: function () {
this.content.style.padding = '20px';
},
onbeforeclose: function () {
return confirm('Are you sure?');
}
});
D面板:
jsPanel.create({
id: 'D',
theme: 'primary',
headerTitle: 'D panel',
position: { my: 'left-top',
at: 'left-bottom',
of: '#A',
autoposition: 'up'
},
contentSize: '450 250',
content: '<p>Test test test</p>',
callback: function () {
this.content.style.padding = '20px';
},
onbeforeclose: function () {
return confirm('Are you sure?');
}
});
阅读“位置”选项的文档,特别是“自动位置”属性,说您可以设置一个值以在面板之间添加间隙以防止它们相互堆积:
'down' 对于使用 'left-top'、'center-top' 或 'right-top' 定位的面板,my: 和 at: 将 autoposition 设置为 'down' 将自动按顺序向每个 elmt 添加一个垂直向下偏移以防止它们相互堆积。删除 jsPanel 将自动将剩余面板重新定位在同一堆栈中。
'up' 对于使用 'left-bottom'、'center-bottom' 或 'right-bottom' 定位的面板,my: 和 at: 将 autoposition 设置为 'up' 将自动按顺序向每个 elmt 添加垂直偏移量以防止它们相互堆积。删除 jsPanel 将自动将剩余面板重新定位在同一堆栈中。
但对我来说,它没有被应用。我试图删除A或D但没有结果autoposition
。
那么我做错了什么或者我误解了什么?
问候。
-- 编辑 1:
我已经实现了分离添加:
offsetY: '8px',
到,panel D
但我认为这不是正确的解决方案......
解决方案
我发现了问题。这是对职位的误解。看到将面板添加到另一个下方的示例编号 5 ,这些位置是:
my: 'right-top',
at: 'right-top',
然后你设置:
autoposition: 'down',
所以在面板 DI 中必须改变:
position: { my: 'left-top',
at: 'left-bottom',
of: '#A',
autoposition: 'up'
},
至
position: { my: 'left-top',
at: 'left-top',
of: '#A',
autoposition: 'down',
offsetY: 4px
},
offsetY
是可选的。默认情况下,JsPanel添加4px分隔,但如果您查看图像,则水平分隔为4px + 4px,因此我添加了 4 个额外像素以在视觉上匹配水平分隔和垂直分隔。
问候!
推荐阅读
- ios - iOS - 渐变之间的过渡?
- java - 上下文右键单击将链接另存为
- python - 我想在我的表单中将图像字段设为可选。我尝试了空白 = True 但它不起作用?
- kubernetes - 在 2 个区域之间平衡 redis 集群
- c++ - 将动态分配的数组分散到 MPI 中的所有进程后,是否可以删除主级别中的动态分配数组?
- javascript - 如果同一行中的 span 包含文本,则 XPath 评估返回锚点 href
- corda - Corda:在响应者流中发出 HTTP 请求?
- python-3.x - 如何将生产变量传递给 Authorize.Net API?
- python - Python 枚举:用 `element.value` 替换 `element`
- java - 无法理解 JPanel 的 setBackground 方法行为