LifeRay门户画布调整大小

liferay portal canvas resize

本文关键字:调整 布调整 LifeRay      更新时间:2023-09-26

我正在使用 three.js 将 webgl 嵌入到 liferay portlet 中。我希望能够在对影响 Portlet 大小的页面布局进行更改时让渲染器调整图像(canvas 元素)的大小。所以基本上每当 portlet 调整大小时,我都希望能够通过三个.js调用来调整画布的大小。三.js有一个渲染器对象,我可以通过它设置大小。问题在于获取组件的宽度。有没有办法捕获重绘事件并获取用于调整画布元素大小的 portlet 宽度?

谢谢

您可以在Liferay上收听portletMovedupdatedLayout事件。

Liferay.on('portletMoved', function(event) {
    var portlet = event.portlet;
    var newWidth = portlet.width(),
        newHeight = portlet.height();
    [...]
});
Liferay.on('updatedLayout', function(event) {
    // Assuming you have Alloy on your script, you can use A.one to get the
    // portlet node. Otherwise, you could use document.getElementById
    var portlet = A.one('#' + portletId);
    var newWidth = portlet.width(),
        newHeight = portlet.height();
    [...]
});