Hi,
How could I automatically resize vertically a panel to fit its content?
On Linux and Windows, fonts are different, widgets are different. In some cases, the bottom text is hidden by the panel boundary or there is a useless bottom margin.
Thanks.
Hi,
How could I automatically resize vertically a panel to fit its content?
On Linux and Windows, fonts are different, widgets are different. In some cases, the bottom text is hidden by the panel boundary or there is a useless bottom margin.
Thanks.
Here is the answer to my own question.
It’s possible to calculate the height of a HTML structure with the bottom element.
In “panel.js”:
self.port.on("calculateHeight", function () {
self.port.emit("setHeight", document.getElementById("lastelem").offsetTop + document.getElementById("lastelem").offsetHeight);
});
In “main.js”, you just have to call this function in “onShow”:
xPanel = panel.Panel({
contentURL: self.data.url("panel.html"),
contentScriptFile: self.data.url("panel.js"),
onShow: function () {
xPanel.port.emit("calculateHeight");
},
});
xPanel.port.on("setHeight", function (n) {
xPanel.resize(800, n);
});