The Dynamic Layer Object API
The Dynamic Layer Object API (DynLayer) is a lightweight object (weighing in at 9 KB) that provides a highly flexible manner of working with layers. Not only does it have common properties and methods for manipulating layers, it is an object based API which opens up a new way of working with layers that far exceeds the traditional way of coding DHTML. I've found it to be the ideal foundation for nearly every application of DHTML including animation, applications, and gaming environments.
You can add more methods or properties onto it, or remove whatever parts you feel you won't need. Many of the next lessons in this tutorial will use the DynLayer as the basis for accomplishing some other task, so it is important that you understand how it works and how to use it.
Features of the DynLayer Object:
- an object-based API that is easy to implement as use
- targets in a similar manner that I've used pointers to target layers - to avoid the problems of the different object models between Netscape and IE
- automatic nested layer handling
- full support for working with layers in separate frames
- provides it's own properties and methods for changing the location of the layer - to avoid the position problems associated with Microsoft's proprietory way of changing the location
- has the handy hide() and show() methods to change the visibility
- exposes a common event model for layer-based events
- has built-in slide, clip, and write methods
- css() function to auto-generate CSS syntax
- easy to make extensions such as wipe, glide, background color, external source files etc.
March 25 Changes:
- Now incorporating a new browser check object, read the BrowserCheck Object lesson for more info
- Renamed the event property to elm (element). This will be needed more in IE 5/Netscape 5. I have left the event property in there (a duplicate) just for backward compatibility.
- Added a DynLayer.useTest property (boolean) to determine if you want the DynLayer to use the DynLayerTest() function to double check everything before assigning the object.
- Minimal support for Mozilla/Netscape 5 - the css,doc,elm properties should work okay. There will be more additions in the future, this is mostly just a placeholder for now.
- IE 5.0 Fixes:
I should point out what I changed to make the DynLayer compatible with IE. I was using the pixelLeft, pixelTop, pixelWidth, and pixelHeight properties to capture the initial CSS properties. Well, Microsoft decided that they didn't want this so now I use offsetX, offsetY, offsetWidth, and offsetHeight. That's it, that's all that's really changed.
The Dynamic Layer Object API
copyright 1998 Dan Steinman
Casa de Bender