I have added a preloader ... it seems that I don´t need a separate variable for each image. As far as I understood, the creation process starts to load the image. I even found shorter versions: "new Image().src = pictureArray[i];" without assigning it to a variable!
... it seems to work, but maybee someone can help testing?
what I did:
new Document
alias: preload.js
template: (blank)
content type: text/javascript
content:
function preloadImages()
{
var pictureArray = new Array([!Ditto?parents=`[[UltimateParent]]`&depth=`0`&tpl=`js_array`&display=`all` &filter=`hidemenu,0`!] "");
for (i=0; i < pictureArray.length; i++) {
Bild = new Image();
Bild.src = pictureArray[i];
}
}
(uses Ditto & UltimateParent!)
new Chunk
name: js_array
content:
[+hintergrundBild:ne=``:then=`"[+hintergrundBild+]", `+]
(uses PHX!)
added to template:
<script type="text/javascript" src="de/preload.js"></script>;
<script type="text/javascript">
window.addEvent('domready', function(evt){ // I used the mootools "domready" event. could also be called in the body-tag
...
preloadImages();
});
</script>
thanks!
@rasc:
I will leave the small line-height for the quote – I like this compact style. but thanks a lot!