(First: sorry people for this long post.. but this is fun isn't it :)
Here's the new createElement of my Dynacore code, I removed all
functionality not available in your code, and then used the timing test you
posted a few days ago..
I personally don't believe in these tests (running it a few times will give
different numbers.. so browsers are not very stable on handling stuff) but
please run the test your self (not sure if the code below works in current
dynapi). I used a test with 500 layers.. your code 2100ms, my code 1980ms..
so I'd say we break even.
As you can see I had to take out ALOT of functionality not available in your
code (recycle array, setting up the images for event triggering, invoking
events on all child layers, setting bgimage + fixing the IE5.5 event bug,
the getContentWidth/height checks and calls)
Also I took another look at your nested test.. that's not valid. When people
use the code (or widgets) usually the child layers are added to the parent
layer, BEFORE the parent layer is added to the document (created). This is
the beauty and power of the precreation.. all those child layers will then
not be created but written into the parent (skipping ALOT of overhead by not
having to call the createelement and having to be inserted into the
document, or have every CSS style be set seperatly)
I think your code could also do with a little optimisation (seeing that your
using the dynapi code for a large part) but I don't think the differences in
speed (between dynlayer and canvase) would be that big.. once I get this
optimising round done and checked, I'll try to work these things into the
official DynAPI.
I AM very interested in any documents to back up your ideas about how the
objects are passed..but for now you still don't have me convinced there's a
noticeable difference to be gained ;-)
If you want I can post the current Dynacore "snapshot", but here's my
current createElement code (people this is NOT a patch)
DynLayer.prototype.createElement=function() {
// if (this.created||!this.parent||this.elm!=null) return
if (this.parent.isDocument) this.dyndoc=this.parent
else this.dyndoc=this.parent.dyndoc
if (is.ns4) {
// var recycled=this.parent.doc.recycled
// if (recycled && recycled.length>0) {
// this.elm=recycled[0]
// DynAPI.removeFromArray(recycled,recycled[0])
// } else {
this.elm=new Layer(this.w,this.parent.elm)
this.elm.captureEvents(Event.LOAD)
this.elm.onload=function() {}
// }
this.css=elm
this.doc=elm.document
this.doc.lyrobj=this
// for (i in this.doc.images) this.doc.images[i].lyrobj=this
} else var
parentElement=(this.parent.isLayer)?this.parent.elm:this.parent.doc.body
if (is.ie4) {
var code='<DIV id="'+this.id+'" style="position:absolute; left:0px;
top:0px; width:'+this.w+'px;"></DIV>'
parentElement.insertAdjacentHTML("beforeEnd", code)
this.elm=parentElement.children[parentElement.children.length-1]
this.css=this.elm.style
this.doc=this.parent.doc
// for (i in this.elm.all.tags("img"))
this.elm.all.tags("img")[i].lyrobj=this
} else if (is.ie5 || is.ns5) {
parentElement.appendChild(this.elm=this.dyndoc.doc.createElement("DIV"))
this.elm.style.position="absolute"
this.elm.id=this.id
this.css=this.elm.style
this.doc=this.parent.doc
// if (is.ns5) for (i in this.doc.images)
this.doc.images[i].lyrobj=this.elm
// if (is.ie5) for (i in this.elm.all.tags("img"))
this.elm.all.tags("img")[i].lyrobj=this
}
this.elm.lyrobj=this
// for (var i=0; i<this.children.length; i++)
this.children[i].invokeEvent('precreate')
// this.invokeEvent('precreate')
this.setSize(this.w,this.h,false)
if (is.ns4) {
this.elm.moveTo(this.x,this.y)
this.doc.write(this.getInnerHTML())
this.doc.close()
} else {
this.css.left=this.x
this.css.top=this.y
this.setHTML(this.html) //this.getInnerHTML())
}
if (this.bgColor!=null) this.setBgColor(this.bgColor)
// if (this.bgImage!=null) this.setBgImage(this.bgImage)
// else if (is.ie55 && this.html==null) this.setBgImage('javascript:null')
// if (this.clip!=null) this.setClip(this.clip)
// this.css.zIndex=this.z
this.css.visibility=this.visible? "inherit" : (is.ns4?"hide":"hidden")
// this.assignChildren()
// if (this.html!=null) {
// if (this.w==null && this.getContentWidth()>0)
this.setWidth(this.getContentWidth(), false)
// if (this.h==null && this.getContentHeight()>0)
this.setHeight(this.getContentHeight(), false)
// }
// if (this.hasEventListeners) {
this.captureMouseEvents()
// var elm=this.elm
// if (is.ns4) elm.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP |
Event.CLICK | Event.DBLCLICK)
//
elm.onmousemove=elm.onmousedown=elm.onmouseup=elm.onmouseover=elm.onmouseout
=elm.onclick=elm.ondblclick=DynObject.prototype.EventMethod
// if (is.ie5) elm.oncontextmenu=function(){return false}
// }
// this.created=true
// this.invokeEvent("resize")
// this.invokeEvent('create')
}
Pascal Bestebroer
[EMAIL PROTECTED]
http://www.dynamic-core.net
_______________________________________________
Dynapi-Dev mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/dynapi-dev