问题
Panel Size is fixed in SDK-based Add-on
I want to change the size of panel automatically like chrome dictionary extension here
If you will search in panel it will show big and small data like content requirement.
In Mozilla panel we can fix only 1 type of size like width:400px
and height:400px
etc. but i want that panel size should based on data size means like chrome extensions.
回答1:
You can implement this in the Add-on SDK with a little extra code.
In main.js:
var panel = require("panel").Panel({
contentURL: "https://bugzilla.mozilla.org/enter_bug.cgi?product=Add-on%20SDK",
onShow: function() {
let worker = tabs.activeTab.attach({
contentScriptFile: [
data.url('windowsize.js')
]
});
worker.port.on('winsize', function(data) {
panel.resize((data.width-120), (data.height-120));
});
worker.port.emit('fetchwinsize');
}
});
In the content script:
self.port.on('fetchwinsize', function() {
self.port.emit("winsize", {height: window.innerHeight, width: window.innerWidth});
});
Here's a working example of this:
https://builder.addons.mozilla.org/package/150225/latest/
来源:https://stackoverflow.com/questions/14123936/how-to-change-panel-size-in-mozilla-like-chrome-extension