As many of you've been wanting the auto-sizing of layers to work in Mozilla/NS6 maybe I should share what I found worked for me.
First of all, I don't use DynAPI myself which is why I haven't supplied a patch. Somewhere around last May/June I took a look at the code, and some of the ideas (at that time at least) I didn't agree with. So I started coding my own variant, but I keep following the discussions here though.
Okay, that said. Now over to what I found worked on my setup. From what I understand the code below will have to be modified to cope with pre-creation code (or maybe disable the pre-creation if the sizes aren't known?).
DynLayer.prototype.createElement = function() {
<...>
if(this.html != "") {
this.setHTML(this.html,false);
// Mozilla M18 (and most probably Netscape 6) bug: doesn't update the offsetXxxx
// values directly. I believe this is delayed to the next update cycle, which happens
// when the JavaScript thread is idle.
// A suggested workaround is to call blur() ... focus() but testing revealed that
// doesn't fix the problem.
// http://bugzilla.mozilla.org/show_bug.cgi?id=56810
// http://bugzilla.mozilla.org/show_bug.cgi?id=65548
if(is.mozilla) {
var code = "{var o="+this+";";
if(this.w == null)
code += "o.w=o.getContentWidth();";
if(this.h == null)
code += "o.h=o.getContentHeight();";
code += "o.setSize(o.w,o.h);}";
setTimeout(code, 0);
}
else {
if(this.w == null)
this.w = this.getContentWidth();
if(this.h == null)
this.h = this.getContentHeight();
this.setSize(this.w,this.h);
}
}
else
if(this.w || this.h)
this.setSize(this.w,this.h);
<...>
for(var i=0; i<this.children.length; i++)
this.children[i].createElement();
// Doing the this.html!="" test too would make the oncreate fire in random order for
// children.
// If we didn't have any html to print but a child does, this object would fire the event
// before the child does.
if(is.mozilla /*&& this.html!=""*/)
setTimeout(this+'.fireEvent("create")', 0);
else
this.fireEvent("create");
}
I hope this will help getting auto-sizing to work.
/Lunna
|