
Originally Posted by
Twey
Nice work. A word about constructor parameters: it's not usually a good idea to have optional parameters to the constructor, since if one has more than one, the user has to enter all the parameters if s/he only wants to set the last one (and it leads to long chains of incomprehensible values). Rather, a setter function for each optional parameter is usually a better idea. Also, of course, every parameter that can be made optional, should be made optional -- the only parameter I can see there that can't have a suitable default value is gallery_array_name.I'd think that the odd goings on were probably the original reason for the onload event, since I can't see object-orienting a script removing the need for an onload event.
Code:
if(document.body.filters)
thewin.resizeTo(actualWidth+12, actualHeight+70);
Ouch, browser detection.
Thanks, I like your suggestions and will consider them for future work. I was following the template established by DD's Ultimate Fade-in script, as mentioned. Folks seem to do OK with it, not too many parameters and it does insure that the uninitiated will at least probably consider that certain parameters should be set to get any particular look to the script. I truly see how adding more parameters would get unwieldy. I think I stumbled upon a neat way to deal with additional parameters with my:
Code:
// Use a space character between each image for this gallery? (use 1 for yes, 0 for no):
gallery.usespace=1;
Which I think is assigning a property to the array object used by the function object, making it uniquely accessible to that particular thread of the function object as this.gallery.usespace.
About the browser detect, I wasn't real happy about that but, IE is the only browser that I am aware of that can be pretty much be reliably depended upon to resize scripted windows, or that needs to. It's just for the enlarge function anyway, you can use whatever you like or nothing for that part of the script:
Code:
//function used optionally to enlarge an image. Change as desired:
function enlargeimage(path, optWidth, optHeight){
In the original versions, the onload event was a way of ensuring that the browser knew the dimensions of the images involved in the image train before initializing. Folks had complained, if they had a lot of other images on the page, that it took too long to load the gallery. I now check to see if the images involved in the gallery are 'complete'. Seems to work well.
Bookmarks