AlloyUI中可调整面板大小
Resizable panels in AlloyUI
我正在学习AlloyUI,但不知道如何在主布局中设置可调整大小的面板。我尝试了这个方法来调整表的大小,但它并没有起作用,我在控制台中并没有看到任何错误。有人能帮助如何在AlloyUI中调整div元素的大小吗?
这是我的基本布局,其中有3个主面板可以使用jQueryUI:调整大小
http://jsfiddle.net/vLeve252/
这是我的代码,我试图在面板中调整表的大小:
main.html
<!-- main css -->
<link rel="stylesheet" type="text/css" href="resources/styles/main.css" media="all" />
<script src="http://cdn.alloyui.com/2.0.0/aui/aui-min.js"></script>
<link href="http://cdn.alloyui.com/2.0.0/aui-css/css/bootstrap.min.css" rel="stylesheet"/>
</head>
<body>
<div id="layout">
<div id="filter">
<table id="tabl" style="width:100%">
<tr>
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
</table>
</div>
<div id="graph"></div>
<div id="details"></div>
</div>
<script>
YUI().use(
'resize',
'overlay',
function (Y) {
var overlay = new Y.Overlay({
width: "200px",
srcNode: "#tabl",
visible: false,
align: {node:".example", points:["tc", "bc"]}
});
overlay.plug(Y.Plugin.Resize);
}
);
</script>
</body>
main.css
#filter{
position: absolute;
left: 0;
top: 0;
bottom: 0;
width: 20%;
height: 100%;
overflow: auto;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
-ms-box-sizing: border-box;
-o-box-sizing: border-box;
box-sizing: border-box;
border-right: solid 1px #aaa;
}
#details {
position: absolute;
left: 20%;
bottom: 0;
height: 20%;
width: 100%;
border-top: solid 1px #aaa;
}
编辑
我想获得与这里相同的结果,但使用AlloyUI而不是jQuery UI
要使div
s(或任何类型的Node
)可调整大小,您需要将plug()
和Plugin.Resize
类Node
。
没有必要使用Overlay
。相反,您可以使用YUI.one()
将div
获取为Node
。然后您可以在Resize
插件中使用plug()
。这样做的javascript看起来像这样:
YUI().use('resize-plugin', 'node', function (Y) {
Y.one('#filter').plug(Y.Plugin.Resize);
Y.one('#graph').plug(Y.Plugin.Resize);
Y.one('#details').plug(Y.Plugin.Resize);
});
编辑:
然而,要制作一个类似于您在jsFiddle中发布的jQuery的布局有点困难。我的第一个建议是使用jQuery。jQuery解决方案似乎很简单,经过深思熟虑,它可以与YUI/AlloyUI在同一页面上共存,所以对布局使用jQuery,对其他任何内容使用YUI/Alloy UI。
如果你绝对不能使用jQuery,你可以这样做:
HTML
<div id="layout">
<div id="graph"></div>
<div id="details"></div>
</div>
CSS
#layout {
position: absolute;
right: 0;
height: 300px;
width: 300px;
}
#graph {
position: absolute;
height: 200px;
width: 100%;
background: orange;
}
#details {
position: absolute;
bottom: 0;
height: 100px;
width: 100%;
background: navy;
}
javascript
YUI().use('resize-constrain', 'resize-plugin', 'node', function (Y) {
var graphNode = Y.one('#graph');
var detailsNode = Y.one('#details');
graphNode.plug(Y.Plugin.Resize, {
handles: ['b']
});
graphNode.resize.plug(Y.Plugin.ResizeConstrained, {
constrain: '#layout'
});
graphNode.resize.on('resize:resize', function (event) {
var graphHeight = parseInt(graphNode.getStyle('height'), 10);
detailsNode.setStyle('height', (300 - graphHeight) + 'px');
});
});
外植体:
- 用
Resize
插件插入一个Node
,使其可调整大小 - 用
ResizeConstrianed
插件插入Resize
插件,以便只允许在外部div
的宽度内调整大小 关于
resize:resize
事件:- 获取
graph
div
的高度作为Integer
- 将其从总高度中减去,以确定
details
div
的新高度 - 将
details
div
设置为新高度
- 获取
为了完整起见,我包含了一个可运行的示例,它有一个3面板可调整大小的布局,很像jQuery示例:
YUI().use('resize-constrain', 'resize-plugin', 'node', function (Y) {
var graphNode = Y.one('#graph');
var detailsNode = Y.one('#details');
graphNode.plug(Y.Plugin.Resize, {
handles: ['b']
});
graphNode.resize.plug(Y.Plugin.ResizeConstrained, {
constrain: '#rightPanel'
});
graphNode.resize.on('resize:resize', function (event) {
var graphHeight = parseInt(graphNode.getStyle('height'), 10);
detailsNode.setStyle('height', (300 - graphHeight) + 'px');
});
var filterNode = Y.one('#filter');
var rightPanelNode = Y.one('#rightPanel');
filterNode.plug(Y.Plugin.Resize, {
handles: ['r']
});
filterNode.resize.plug(Y.Plugin.ResizeConstrained, {
constrain: '#mainLayout'
});
filterNode.resize.on('resize:resize', function (event) {
var filterWidth = parseInt(filterNode.getStyle('width'), 10);
var rightPanelResizedWidth = (600 - filterWidth) + 'px';
rightPanelNode.setStyle('width', rightPanelResizedWidth);
// YUI sets the height using the `style` attribute, so it must be overwritten using `setStyle()` becuase the CSS has been overriden.
graphNode.setStyle('width', rightPanelResizedWidth);
});
});
#mainLayout {
position: absolute;
height: 300px;
width: 600px;
}
#rightPanel {
position: absolute;
right: 0;
height: 300px;
width: 300px;
}
#graph {
position: absolute;
height: 200px;
width: 100%;
background: orange;
}
#details {
position: absolute;
bottom: 0;
height: 100px;
width: 100%;
background: navy;
}
#filter {
position: absolute;
left: 0;
height: 100%;
width: 300px;
background: darkcyan;
}
<script src="https://cdn.rawgit.com/stiemannkj1/0214fdc4cccaa77d6e504320cf70a571/raw/63d260364730fb067f103c00862c7e65685256df/yui-3.18.1_build_yui_yui-min.js"></script>
<div id="mainLayout">
<div id="rightPanel">
<div id="graph"></div>
<div id="details"></div>
</div>
<div id="filter"></div>
</div>
相关文章:
- Graphiti中的形状有任何可调整大小的限制吗
- 用于显示onclick事件计数的可调整跨度标记
- jQuery UI在React.js中可调整大小
- 如何将可调整大小、可拖动的覆盖添加到网页中
- 可调整滚动条大小
- 添加JQuery UI在Meteor中添加对象后可调整大小
- 使可调整大小的手柄在具有指定尺寸的画布上可见
- 如何使用编辑器制作可调整大小的文本区域
- jQuery 可调整大小() 不起作用(带有示例)
- 使用 ng-hide 切换表中的列,其中 colRessize 可调整大小
- jQuery 可调整大小:如何在调整大小拖动期间获取重叠元素
- 具有无限水平滚动的流体可调整大小图像(修订版 2)
- 如何使用可调整大小的元素重叠其他元素
- 附加jQuery's可调整大小的处理程序
- HTML5画布中的可拖动和可调整大小元素
- imgAreaSelect JQuery插件可调整大小的Div's最小's宽度和高度
- JQuery可调整大小的触摸屏
- 如何在Html中开发可调整大小的交互板
- 我可以在HTML中制作一个可调整的数组列表吗
- AlloyUI中可调整面板大小