0

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

谢谢

4

1 回答 1

0

您可以在 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();

    [...]
});
于 2013-10-24T08:56:26.343 回答