【问题标题】:liferay portal canvas resizeliferay 门户画布调整大小
【发布时间】:2013-10-30 15:49:30
【问题描述】:

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

谢谢

【问题讨论】:

  • 你尝试过使用 width:auto 吗?

标签: javascript canvas three.js liferay


【解决方案1】:

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

    [...]
});

【讨论】:

  • 我在我的 portlet jsp 的 javascript 中尝试了第一个建议的事件。我将其修改为仅在事件发生时发出警报(“portlet 已移动”)。这没有用。我将事件的名称更改为“allPortletsReady”,事件被捕获并发布了警报。我在哪里可以找到 liferay 使用的有效事件名称列表?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-10-06
  • 2011-03-14
  • 2013-12-15
  • 2013-11-19
  • 2014-11-04
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多